Random Sample from Discrete PDF

Inverse transform sampling to generate random sample from pdf given by domain x and p(x).

Al momento, stai seguendo questo contributo

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;

Cita come

Joshua Stough (2026). Random Sample from Discrete PDF (https://it.mathworks.com/matlabcentral/fileexchange/37698-random-sample-from-discrete-pdf), MATLAB Central File Exchange. Recuperato .

Riconoscimenti

Ispirato da: Random Numbers from a Discrete Distribution

Categorie

Scopri di più su Read, Write, and Modify Image in Help Center e MATLAB Answers

Informazioni generali

Compatibilità della release di MATLAB

  • Compatibile con qualsiasi release

Compatibilità della piattaforma

  • Windows
  • macOS
  • Linux
Versione Pubblicato Note della release Action
1.0.0.0