Weighted random numbers in MATLAB
Posted
by yuk
on Stack Overflow
See other posts from Stack Overflow
or by yuk
Published on 2010-06-04T20:18:02Z
Indexed on
2010/06/05
11:22 UTC
Read the original article
Hit count: 158
How to randomly pick up N numbers from a vector a
with weight assigned to each number?
Let's say:
a = 1:3; % possible numbers
weight = [0.3 0.1 0.2]; % corresponding weights
In this case probability to pick up 1 should be 3 times higher than to pick up 2.
Sum of all weights can be anything.
© Stack Overflow or respective owner