adj_logistic.m
来自「The BNL toolbox is a set of Matlab funct」· M 代码 · 共 27 行
M
27 行
function y=adj_logistic(x)
%y=adj_logistic(x) computes probabilities for adjacent-categories logistic
%model
%for nd arrays, sum over dimension nd
%if only one vector, use row vector!
%if size(x,2)==1 error('use row vectors'),end
%if isempty(find(sum(x,1)==0)) error ('one column should consist of zeros'), end
siz=size(x);
shift=prod(siz(1:end-1));
x=reshape(x,shift,siz(end));
y=zeros(shift,siz(end));
d=ndims(x);
for i=1:siz(end)
y(:,i)=exp(sum(x(:,1:i),2));
end
y=y./repmat(sum(y,2),1,size(y,2));
if ~isvector(y)
y=reshape(y,[siz(1:end-1) siz(end)]);
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?