X=randn(2000,1)
Gaussian random variable with mean = 0 and variance = 1
how to transform $X$ to $Y$ that is a Rayleigh distributed?

- 108,699
- 20
- 212
- 390

- 3
- 2
1 Answers
Why exactly would you like to generate Rayleigh distributed values using normal samples?
There are two possible approaches. First, you can use inverse transform sampling. If $U$ is uniformly distributed in $(0, 1)$, then
$$ Y=\sigma\sqrt{-2 \ln(1 - U)} $$
follows a Rayleigh distribution. You can recall that if $F$ is a cumulative distribution function and $X \sim F$, then $F(X)$ is uniformly distributed, so you can take $U = F(X)$ and using normally distributed $X$ transform it to uniform and then transform it to Rayleigh, but this is not very efficient since you could simply start with uniform $U$.
Second, you can use the property that $Y \sim \mathcal{R}(\sigma)$ is Rayleigh distributed if $Y = \sqrt{X^2 + Z^2}$, where both $X \sim \mathcal{N}(0, \sigma^2)$ and $Z \sim \mathcal{N}(0, \sigma^2)$, so if you have two normally distributed variables, you can use them to obtain Rayleigh distributed samples.
As usually, Wikipedia has a nice article about Rayleigh distribution.
-
I want to generate Rayleigh distributed variables only from Gaussian distributed variable X that I obtained from the previous operation on my project . – hamzeh ghanem Apr 12 '17 at 14:06
-
2@hamzehghanem so the first approach is for you or you can use the second approach to obtain half the number of the samples. – Tim Apr 12 '17 at 14:12
-
how i could use the second approach if i have only X (one one Gaussian variables ) ? – hamzeh ghanem Apr 12 '17 at 14:24
-
1@hamzehghanem you have 2000 values, so take first 1000 as X and second 1000 as Z, square them, add and take square root, and you'll end up with 1000 Rayleigh samples. – Tim Apr 12 '17 at 14:27
-
but I want to generate 2000 points Rayleigh from 2000 points Gaussian ? – hamzeh ghanem Apr 12 '17 at 14:33
-
1@hamzehghanem so use the first method... – Tim Apr 12 '17 at 14:41
-
1+1. Note that you can obtain 2,000 iid values of $U$ from 2,000 iid Normal variates by various methods described at http://stats.stackexchange.com/questions/117689 :-) – whuber Apr 12 '17 at 22:18