⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adj_logistic.m

📁 The BNL toolbox is a set of Matlab functions for defining and estimating the parameters of a Bayesi
💻 M
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -