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

📄 multinornd.m

📁 The BNL toolbox is a set of Matlab functions for defining and estimating the parameters of a Bayesi
💻 M
字号:
function R=multinornd(n,p)
%trekken uit multinomiale verdeling
%   n is sample size, p vector of probabilities
d=length(p);
if (sum(p)<.99999 | sum(p)>1.000001)

    error('probabilities must sum to one');
end
if ~isscalar(n) error('n must be scalar'), end
if ~isvector(p) error('n must be vector'), end
R=binornd(n,p(1));
for i=2:d-1
    N=n-sum(R);
    if N==0
        R=[R 0];
    else
    pp=p(i)/sum(p(i:d));
    R=[R binornd(N,pp)];
    end
end
R=[R n-sum(R)];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -