Hello,
I was wondering if anyone knew (or could direct me) of how to generate any probability density function from from a uniform distribution. For example from uniform to Rayleigh (or exponential).
I am interested both in the mathematical derivation and the software implementation (Matlab).
It is very simple!!
You have pass the uniform data (between 0 and one) through the inverse cdf (cumulative distribution function) of the required Distribution. ie if you want to generate a distribution with cdf as 1-exp(-x) for x>0 you have to use -ln(1-x).
the code is also simple:
From your explanation:
You have pass the uniform data (between 0 and one) through the inverse cdf (cumulative distribution function) of the required Distribution.
Working from there I thought that this is what the code should look like:
X=rand(1,1e4);
Y = 1 - exp(-lambda*X);
Where X is the original uniformly distributed data and Y is the exponentially distributed data.
Please let me know if that is correct or if I completely missed the gist of what you were saying.
In order to find the inverse cdf of the exponential distribution I have solved Y=1-exp(-X) for X. This is the point. You have to find algebric inverse.
Also if you jenerate the data using the line you have here, I think you can see that the drived data are not exponentially distributed.