dirichrnd.m
来自「Continuous Profile Models (CPM) Matlab T」· M 代码 · 共 33 行
M
33 行
function r = dirichrnd(p,k)% function r = dirichrnd(p,k)%% generate a random sample from a dirichlet distribution, with% dimentionality vector of parameters (of length n), p.%% k (default k=1) is the number of samples returned%% Depends on 'gamrnd' in the stats toolbox%% Author: Jennifer Listgarten, Aug 12, 2005.if ~exist('k') k=1;endn=length(p);g=zeros(n,k); %store temporary gamma samplesfor dim=1:n g(dim,:) = gamrnd(p(dim)*ones(1,k),1);end counts = sum(g,1);countsRep = repmat(counts,[n 1]);r=g./countsRep;return;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?