Random Sample from Discrete PDF

バージョン 1.0.0.0 (2.07 KB) 作成者: Joshua Stough
Inverse transform sampling to generate random sample from pdf given by domain x and p(x).
ダウンロード: 1.3K
更新 2012/8/1

ライセンスの表示

Generate random samples given a pdf. The x and p(x) are specified in the
arguments. See inverse transform sampling, gaussdis, gammadis.

Examples:
X = pdfrnd(0:.1:20, gammadis(3,2, 0:.1:20), 100000);
figure, hist(X, 100);
%X will be 100000 samples from gamma distribution with a/k = 3, b/Theta =
%2.

X = pdfrnd(-10:.1:10, gaussdis(2, 3, -10:.1:10), 100000);
figure, hist(X, 100);
%X will be 100000 samples from a gaussian distribution with mean 2, var 3.
%Should be roughly equivalent to X = sqrt(3)*randn(100000, 1) + 2;

引用

Joshua Stough (2024). Random Sample from Discrete PDF (https://www.mathworks.com/matlabcentral/fileexchange/37698-random-sample-from-discrete-pdf), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2010a
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersRead, Write, and Modify Image についてさらに検索
謝辞

ヒントを得たファイル: Random Numbers from a Discrete Distribution

Community Treasure Hunt

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

Start Hunting!
バージョン 公開済み リリース ノート
1.0.0.0