cum_logit.m

来自「The BNL toolbox is a set of Matlab funct」· M 代码 · 共 18 行

M
18
字号
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 + =
减小字号Ctrl + -
显示快捷键?