Random Numbers from a Discrete Distribution

Simple algorithm to generate random numbers from a user-defined discrete probability distribution.

Download
Download

You are now following this Submission

Cite As

Tristan Ursell (2026). Random Numbers from a Discrete Distribution (https://au.mathworks.com/matlabcentral/fileexchange/34101-random-numbers-from-a-discrete-distribution), MATLAB Central File Exchange. Retrieved .

Acknowledgements

Inspired: Random Sample from Discrete PDF

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.7.0

plot fixed

Download
1.6.0

replaced older for loop implementation with histc implementation

Download
1.2.0

minor code reorganization, a little faster, a little cleaner.

Download
1.0.0

Download