Random Sample from Discrete PDF
版本 1.0.0.0 (2.1 KB) 作者:
Joshua Stough
Inverse transform sampling to generate random sample from pdf given by domain x and p(x).
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 (2026). Random Sample from Discrete PDF (https://ww2.mathworks.cn/matlabcentral/fileexchange/37698-random-sample-from-discrete-pdf), MATLAB Central File Exchange. 检索时间: .
MATLAB 版本兼容性
创建方式
R2010a
兼容任何版本
平台兼容性
Windows macOS Linux类别
在 Help Center 和 MATLAB Answers 中查找有关 Read, Write, and Modify Image 的更多信息
标签
| 版本 | 已发布 | 发行说明 | |
|---|---|---|---|
| 1.0.0.0 |
