Here is my problem in Matlab:
I have a set of integers e.g. A={10,11,12,...,T} with corresponding densities P={p(10),p(11),P(12),...,P(T)}. How do I randomly sample from A using the weights from P?
Here is my problem in Matlab:
I have a set of integers e.g. A={10,11,12,...,T} with corresponding densities P={p(10),p(11),P(12),...,P(T)}. How do I randomly sample from A using the weights from P?
If you have the Statistics Toolbox, you can use randsample.
X = randsample(A, 1, true, P);
