View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

Join the 15-year community celebration.

Play games and win prizes!

» Learn more

Be the first to rate this file! 21 Downloads (last 30 days) File Size: 2.46 KB File ID: #41689 Version: 1.0




A simple and handy PDF (Probability Distribution Function) re-constructor and sampler.

| Watch this File

File Information

PDFsampler is a MATLAB class that serves as a random number generator for custom probability distribution functions and is particularly useful for Monte Carlo simulations. Objects of this class are initialized using samples of your custom distribution of using histogram data of your PDF. It is well documented and pretty straight forward to use.

Required Products MATLAB
MATLAB release MATLAB 8.0 (R2012b)
Other requirements The class makes use of core MATLAB functions and is expected to be backwards compatible with older versions.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
18 Sep 2016 Minh Cao

Hi Pantelis,
Could you please tell me the name of the reconstruction method you are using? Perhaps a link to some research paper that references it?

Comment only
01 Jul 2016 Pantelis Sopasakis

@JonathanMayers: PDFSampler works with discrete distributions. You can pass the outputs of `hist` to its constructor.

Example #1:
random_numbers = [ ... ]; % some array
[v, p] = hist(random_numbers, 50);
sampler = PDFSampler(v, p);

#Example #2:
% In case you have an array of data
% You can pass it directly to the constructor:

In any case, you sample from the PDF using `sampler.nextRandom`

Comment only
25 May 2016 Jonathan Mayers

Thanks for this. I am not sure how to use the class for a custom pdf. Could you please provide an example of this?

Comment only
18 Oct 2013 Pantelis Sopasakis

An example of use can be found at

Comment only

Contact us