Tuesday, August 2, 2011

Matlab Simulation - General Discrete Distribution (multivarite)

1. one option is built in randsample with weighted option, you sample with certain weights.

There are CFX options
2. Discrete (multinomial) distribution sampler

http://www.mathworks.com/matlabcentral/fileexchange/25481-discrete-multinomial-distribution-sampler

3. randp
http://www.mathworks.com/matlabcentral/fileexchange/8891

Matlab Simulation: Weighted Without Replacement Sampling

1. matlab's randsample doesn't handle this


Y = RANDSAMPLE(...,true,W) returns a weighted sample, using positive
    weights W, taken with replacement.  W is often a vector of probabilities.
    This function does not support weighted sampling without replacement.

2. Someone on CFX wrote a file for this
http://www.mathworks.com/matlabcentral/fileexchange/27263-modified-randsample
Returns V, a weigthed sample of K elements taken among X without replacement
X a vector of numerics
K amount of element to sample from x
W a vector of positive weights w, whose length is length(x)

3. I think this will take care of multivariate hypergeometric sampling. That is sampling without replacement when there are multiple types, because the different types each have a different probability of being selectted.