Generalized Dirichlet-Multinomial distribution
A demo of random number generation, density evaluation, and distribution fitting for the generalized Dirichlet-Mutlinomial distribution
Contents
Generate generalized Dirichlet-Multinomial random vectors
clear; % reset random seed s = RandStream('mt19937ar','Seed',1); RandStream.setGlobalStream(s); % sample size n = 100; % # bins d = 5; % true parameter values alpha = 1:d-1; beta = d-1:-1:1; % set batch sizes (ranges from 25 to 50) batchsize = 25+unidrnd(25,n,1); % generate random vectors X = gendirmnrnd(batchsize,alpha,beta,n);
Evaluate gen. Dirichlet-Multinomial (log) pdf at true parameter value
logL = gendirmnpdfln(X,alpha,beta); display(sum(logL));
-1.0604e+03
Fit generalized Dirichlet-Multinomial distribution
tic; [alpha_hat, beta_hat, stats_gdm] = gendirmnfit(X); toc; display([alpha_hat, beta_hat]); display(stats_gdm.se); display(stats_gdm);
Elapsed time is 0.026425 seconds.
1.2048 5.1594
1.4605 2.9081
4.4444 3.0886
2.8421 0.8244
0.2047 0.9637
0.2351 0.4938
0.8990 0.6189
0.7449 0.1996
stats_gdm =
struct with fields:
se: [4×2 double]
gradient: [2×4 double]
dof: 8
logL: -1.0503e+03
BIC: 2.1373e+03
AIC: 2.1165e+03
LRT: 933.3728
pvalue: 0
iterations: 6