Various different techniques and examples for generating random numbers from specific distriubtions on MATLAB.
Acceptance Rejection method
Box-Muller method
(Normally distributed)Fibonacci method
Marsaglia method
(Normally distributed)Linear Congruential Generator
Dear reader,
One topic that has come up time and time again during my learning is generating specific random numbers. It is a useful technique to understand how computers go about generating the random numbers they do, be that on MATLAB, Python, or even MS Excel. That being said, however, it strongly recommended that you do not implement your own random number generator in your work unless the task explicitly asks for it. Instead you should always look to use the in-built functions as they will be far more robust and, in general, create a much longer non-repeating sequence. Truly random numbers cannot be generated computationally (yet) and as such the majority of methods rely on a seed number.
The scripts may not be perfect, but I hope these give you some insight.
H ✌️
Terms & Conditions
This repository and the code therein may be freely copied and distributed as necessary. It is being provided solely for information and general illustrative purposes. The author will not be responsible for the consequences of reliance upon the code or for numbers produced from using the code.
Where appropriate, this repository is in compliance with Section C. Acceptable Use and Section D. User-Generated Content of the GitHub Terms of Service. For more information, please see here: https://docs.github.com/en/site-policy/github-terms/github-terms-of-service