How do I generate a sampled sequence with frequncy p(n)
이전 댓글 표시
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
답변 (1개)
Jos (10584)
2014년 9월 22일
X = [10 20 30] % observations
p = [50 30 20] % (relative) probabilities
N = 20 ;
i = randp(p,1,N)
Sample = X(i)
카테고리
도움말 센터 및 File Exchange에서 Multivariate Distributions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!