Discrete (multinomial) distribution sampler
by Michael Chen
03 Oct 2009
(Updated 07 Nov 2009)
Random number generator of a discrete (multinomial) distribution
|
Watch this File
|
| File Information |
| Description |
Generate samples from a discrete distribution or multinomial distribution specified by discrete probability parameters.
usage:
x = discreternd(p,n);
p is a vector of the discrete probabilites (sum(p)==1)
n is the desired number of samples.
if length(p)==d, then x is a vector of n integers in [1,d].
example
>> discreternd([.2,.3,.5],10)
ans =
1 3 3 2 3 1 2 3 3 3 |
| MATLAB release |
MATLAB 7.9 (2009b)
|
|
Tags for This File
|
| Everyone's Tags |
|
| Tags I've Applied |
|
| Add New Tags |
Please login to tag files.
|
| Updates |
| 07 Nov 2009 |
greatly speed up by utilizing build in histc function |
|
Contact us at files@mathworks.com