Generate random samples from arbitrary discrete probability density function in Matlab
古いコメントを表示
I've got an arbitrary probability density function discretized as a matrix in Matlab, that means that for every pair x,y the probability is stored in the matrix: A(x,y) = probability
This is a 100x100 matrix, and I would like to be able to generate random samples of two dimensions (x,y) out of this matrix and also, if possible, to be able to calculate the mean and other moments of the PDF. I want to do this because after resampling, I want to fit the samples to an approximated Gaussian Mixture Model.
I've been looking everywhere but I haven't found anything as specific as this. I hope you may be able to help me.
Thank you.
採用された回答
その他の回答 (2 件)
Walter Roberson
2015 年 7 月 28 日
編集済み: Walter Roberson
2015 年 7 月 28 日
nA = numel(A);
numsamples = 20;
samples = A(randi(nA,[numsamples,1]));
This assumes you want to uniformly sample from the matrix. If you do not, then you will need to specify your sampling method.
1 件のコメント
Miguel Encinas
2015 年 7 月 28 日
編集済み: Miguel Encinas
2015 年 7 月 28 日
Torsten
2015 年 7 月 28 日
0 投票
Take a look at the second example under
Best wishes
Torsten.
カテゴリ
ヘルプ センター および File Exchange で Noncentral t Distribution についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!