MATLAB: How to generate random number from cumulative distribution function (CDF) in Matlab

distributionrandom number generator

Hi everyone,
Similar to R program, I'm looking for a code in Matlab that I can generate a set of random number with a specific mean (M) and standard deviation (sd).
R code to generate random number with normal distribution from CDF:
> pnorm(1.96, mean=0, sd=1)
[1] 0.9750021

Best Answer

For the more general case of an arbitrary CDF , you have to use inverse transform sampling. Attached is an example for generating a Rayleigh transform.
Related Question