How do I generate a sampled sequence with frequncy p(n)

1 Ansicht (letzte 30 Tage)
Bernardo
Bernardo am 22 Sep. 2014
Beantwortet: Jos (10584) am 22 Sep. 2014
I have a 1xn vector of observations X(n)and a vector of probabilities p(n). How do I simulate sampling from this distribution where the frequency of picking observation x(n) is proportional to p(n)? Thanks

Antworten (1)

Jos (10584)
Jos (10584) am 22 Sep. 2014
See RANDP on the file exchange
X = [10 20 30] % observations
p = [50 30 20] % (relative) probabilities
N = 20 ;
i = randp(p,1,N)
Sample = X(i)

Kategorien

Mehr zu Signal Generation and Preprocessing finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by