# Is it possible to convert a Rayleigh distribution into a Gaussian distribution?

...and how might we do this? If possible, I am curious if outliers in the Rayleigh distributed data would also remain outliers in the new Gaussian distributed data. Thanks.

If you know the Rayleigh parameter, then the conversion to a standard normal is readily achieved by the probability integral transform followed by an inverse normal cdf. If $X\sim\text{Rayleigh}(\sigma)$, with cdf $F_\sigma(x)$, then $F_\sigma (X)$ is uniform, and $\Phi^{-1}(F_\sigma (X))$ is standard normal (where $\Phi$ is the standard normal cdf).

If $\sigma$ is unknown we are left with one kind of approximation or another (even estimating $\sigma$ involves approximation). Since the square of a Rayleigh random variable is a special case of the gamma, the Wilson-Hilferty transformation (cube root in the case of the gamma) should produce a good approximation of normality. That is, if $X\sim \text{Rayleigh}$, then $X^{2/3}$ should be fairly normal looking. In practice it looks like a slightly smaller power, somewhere near 0.6, might be a little closer.

$\text{ }$

Here's a comparison of the exact transformation (x-axis) and the three power transformations above (y-axis): The black is the 0.6 power, the red is the 2/3 power and the green is the 1/2 power. The one that most closely reproduces the exact transformation should lie closest to a straight line ... and that looks to be the green line.

(Added in edit: I've checked more carefully; of those three, the green line is nearest to straight overall, but the black line is straighter in the right tail. All three give distributions that are pretty nearly normal - but I should have asked why you needed normality.)

--

An additional discussion on powers of exponential - and hence of Rayleigh - variables:

Powers of exponential random variables are distributed as Weibull. Specifically, if $X$ is exponential, $X^\frac{1}{k}$ is Weibull with shape parameter $k$.

So cube roots and fourth roots of exponentials (Rayleigh variables to the powers $\frac{2}{3}$ and $\frac12$ respectively) will be Weibull with shape parameters $3$ and $4$.

While no Weibull is symmetric, particular choices for $k$ will produce Weibull distributions with zero skewness (different choices for different measures of skewness).

Here are the values of $k$ that have $0$ skewness for several skewness measures and the corresponding power ($p$) of the Rayleigh:

• 3rd-moment skewness: $\:\,\, k=3.60,\, p=0.56$
• mean-median skewness: $k=3.44,\, p=0.58\,$ (second Pearson skewness)
• mean-mode skewness: $\:\,\, k=3.31,\, p=0.60\,$ (first Pearson skewness)
• mode-median skewness: $k=3.26,\, p=0.61$

So it's little surprise that a value of $p$ near $0.6$ would appear suitable.

--

In respect of the issue with outliers:

Can you define what you mean by 'outlier'? If the data has values that don't actually come from the Rayleigh distribution, the question of transforming Rayleigh-distributed data is irrelevant, since you don't have Rayleigh-distributed data.

So if you have values from some distribution that's not Rayleigh (with values that a discrepant for a Rayleigh model) and you transform to normality as if it were Rayleigh, then you definitely end up with a non-normal result ... one which will likely have discrepant-looking values relatively to a normal model.

In the absence of a specification of what makes an outlier, here's an example: This is the same data as above (a large sample from a Rayleigh distribution with $\sigma=1$). In the second panel I have added four outliers (at 6, 10, 30 and 100), marked in red. In the third panel, we see the effect of the power $p=\frac{2}{3}$ and in the last panel the effect of the power $p=\frac{1}{2}$. Note that for the Rayleigh data, $\mu+3\sigma$ is at about 3.22. The value at 6 is already far enough away as to be considered highly unlikely even in a quite large sample with that level of skewness -- an outlier in some sense. You can see that the transformation brings it back toward the main part of the data, so that by the last panel it's visually a somewhat mild outlier, fairly borderline given the sample size (about 4.5 sd's above the mean).

The value 10 (on the original scale), while clearly an outlier, is noticeably less discrepant but still clearly inconsistent with the idea that the data are normal, and the larger values even more so.

So they do in some sense "come in" -- but as to whether the status of them being 'outliers' has changed depends very much on how you define 'outlier'.

--

The suggestion of a fourth root for a gamma* with small values of the shape parameter is in Hawkins and Wixley (ref below). While the Wilson-Hilferty works best over a wide range of gamma distributions, the Hawkins-Wixley does seem to do a little better in some parts of the low-end (smaller values of the shape parameters). That fourth root of a gamma corresponds to a square root of a Rayleigh.

*(NB chi-square is a gamma with a particular scale, and when looking at power transformation, the scale won't matter. So even though both references seem to be about chi-square distributions, their conclusions apply to gamma distributions more generally)

Wilson, E. B., and Hilferty, M. M. (1931),
"The Distribution of Chi-Squares,"
Proceedings of the National Academy of Sciences, 17, 684–688.

Hawkins, D. M., and Wixley, R. A. J. (1986),
"A Note on the Transformation of Chi-Squared Variables to Normality,"
The American Statistician, 40, 296–298.

• Gleb_b thank you very much, let me make sure I understand you. Since I do not in fact know my Rayleigh $\sigma$ parameter, are you saying that I can simply take my data, raise it to the $\frac{2}{3}$ power, and thus produce new data with a good approximation to normality? (As a result of Wilson-Hilferty transformation)? This is very useful! – Creatron Feb 10 '14 at 23:54
• That's the idea, yes. However, the Wilson-Hilferty is for a wide range of gamma shape parameters, while the square of a Rayleigh is a specific one (the exponential with unknown scale); at the low end the W-H might be slightly improved on - in the new additions to my answer I suggest you might consider a value between the 1/2 and the 2/3 power. The 2/3 power is pretty good, and has some justification because of the Wilson-Hilferty, but you might like to try some simulated Rayleigh data (as I did above) and see if you like a smaller one a bit better. – Glen_b -Reinstate Monica Feb 11 '14 at 0:00
• Glen_b, The 0.6 one looks to be the best on my eye. This is really cool and interesting! To answer your question about the outliers: I have nominally Rayleigh distributed data, but ~ < 1% are corrupt and have inordinately large values. I was wondering if putting this data through a transformation to make it gaussian, would also preserve the "outlierness" of the corrupted data. Does that make sense? – Creatron Feb 11 '14 at 0:13
• Actually, considering the square root of the Rayleigh for a second, that looks pretty good and is nice and simple; that corresponds to a fourth-root of a gamma random variable and that transformation has been suggested by one pair of authors (I can probably dig up a reference if you use the square root and need a reference). But pick whichever you prefer. Yes, the extreme outliers will still tend to look extreme, though perhaps 'sticking out' a bit less than before. It depends on precisely how you conclude an observation is an outlier both before and after. – Glen_b -Reinstate Monica Feb 11 '14 at 0:13
• Power transformations are fairly common in statistics; especially parameterized in the Box-Cox family, but see also 'Tukey's ladder'. You might find the following paper (which discusses both references above) of some value: here. I believe the authors also have a book which discusses some of this stuff. – Glen_b -Reinstate Monica Feb 11 '14 at 1:27

If $R$ is a Rayleigh random variable and $\Theta \sim U[0,2\pi)$ is independent of $R$, then $X=R\cos \Theta$ and $Y=R \sin \Theta$ are independent zero-mean normal random variables with identical variance $\sigma^2 = \frac{1}{2}E[R^2]$. Thus, if you transform your data set as $$\{r_1, r_2, \ldots, r_n\} \longrightarrow \{r_1\cos \theta_1, r_2\cos \theta_2, \ldots r_n\cos \theta_n\}$$ (similarly for $Y$ but using $\sin \theta_i$) where $\{\theta_i\colon 1 \leq i \leq n\}$ is a data set that you create as a sequence of independent samples drawn from $U[0,2\pi)$,, then the resulting data set is exactly a collection of $n$ samples from a $N(0,\sigma^2)$ distribution. Note that in contrast to the monotone transformations suggested in @Glen_b's answer, the resulting data set has both positive and negative numbers in it.

• A Rayleigh-distributed data set can have outliers that are very large, but since these will get multiplied by a cosine, which has magnitude less than $1$, they might not be outliers any more unless the cosine has magnitude close to $1$, as noted in Glen_b's comment. Note also that if $\cos \theta_i$ is close to $-1$, then this outlier will still be an outlier but in the other tail.

• If $E]R^2]$ is quite large, then a Rayleigh-distributed data set can also have very small outliers: sample values that are very close to $0$ while almost all of the other sample values are closer to the (large) sample mean. Such outliers will become very close to the mean when they undergo the transformation that I suggest above. With Glen_b's transformation, such outliers will remain small outliers.

In short, the transformed data set does not enjoy the property that outliers in $\{r_i\colon 1 \le i \leq n\}$ are outliers in the transformed data set $\{r_i\cos \theta_i\colon 1 \le i \leq n\}$. If you are willing to have a transformed data set that is twice as large, then the set $$\{r_1\cos \theta_1, r_2\cos \theta_2, \ldots r_n\cos \theta_n\} \cup \{r_1\sin \theta_1, r_2\sin \theta_2, \ldots r_n\sin \theta_n\}$$ is a set of $2n$ independent samples drawn from an $N(0,\sigma^2)$ distribution, and since $\max \{|\cos \theta |, |\sin \theta |\} \geq 1/\sqrt{2}$ you are guaranteed that each large outlier gives you two numbers at least one of which might well still be an outlier, since outlying is, like beauty, in the eye of the beholder. Is something just $20\%$ larger than the next smaller value an outlier? or would you insist on $50\%$ larger? I suppose it depends on the scale factors etc.

• +1 This is both interesting and answers the question as it stands. I assumed the OP wanted a monotonic transformation, but there's nothing in the question that actually says so. A refreshing and somewhat unexpected take on it. – Glen_b -Reinstate Monica Feb 11 '14 at 0:27
• Thanks @Dilip. My starting point is Rayleigh data. (ie, a couple hundred points that are nominally rayleigh). ...I am not clear as to how you are transforming it to gaussian data the way you have up here. – Creatron Feb 11 '14 at 0:39
• @Creatron See the edited version of my answer. – Dilip Sarwate Feb 11 '14 at 0:44
• Creatron: The basic idea: if you take exactly Rayleigh data and multiply by the cos of a random uniform angle, you get exactly normal data. The transformation is exact, but not order-preserving (that is, large observations may end up small, or large, or in the middle). – Glen_b -Reinstate Monica Feb 11 '14 at 1:03
• @DilipSarwate Oh, I see what you mean. I ran some sims and it seems that although I sometimes end up with an outlier in the transformed data, (Sometimes the cos(theta)*outlier remains large, sometimes it becomes small, and sometimes it does not). So this is a hit or miss type of transform? – Creatron Feb 11 '14 at 1:19