Tuesday, August 2, 2011

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.

1 comment:

  1. 1. I wonder if it works sampling like this. I mean, will a sampling without replacement know to change the weights as the

    Alternatively you could use the multivariate hypergeometric distribution pdf and then sample with this pdf?
    http://www.mathworks.com/matlabcentral/fileexchange/25394-mhygepdf/content/mhygepdf.m

    ReplyDelete

Note: Only a member of this blog may post a comment.