📄 cum_logit.m
字号:
function y=cum_logit(x)
%every column of x is prob vector of size k, y is cumulative logit of length k-1
%if only one prob vector, use row vector!
if isvector(x)
if (size(x,2)==1), error('sum of rows =1, input should be row vector! ');,return,end;
end
d=ndims(x);
if d>2 error('cum_logit only defined for vectors and matrices'),return,end;
if prod(sum(x,d))<.999 | prod(sum(x,d))>1.001 error('one of the x is not a probability vector, sum(x)~=1');,return,end;
for i=2:size(x,2)
y(:,i-1)=log(sum(x(:,i:end),2)./sum(x(:,1:i-1),2));
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -