# I Rayleigh distribution and the probability of a point

1. Aug 9, 2018

### rabbed

Okay, so I just found out about the Rayleigh distribution being the radial distribution of a point composed of normal distributed cartesian components. And this is because of the area element, right?
But how then can the joint density of the cartesian component's distributions equal that of the angular and radial distributions? Both should give the density of such a point?

Last edited: Aug 9, 2018
2. Aug 9, 2018

### tnich

I am not sure what you mean. The densities are not equal.
$\frac {exp \{-\frac {x^2 + y^2} {2 \sigma^2}\}}{2\pi \sigma^2} \ne \frac r {\sigma^2} e\{-\frac {r^2}{2 \sigma^2}\}$

But
$\frac {exp \{-\frac {x^2 + y^2} {2 \sigma^2}\}}{2\pi \sigma^2}~dx~dx = \frac r {\sigma^2} e\{-\frac {r^2}{2 \sigma^2}\}~r~dr~d\theta$
when $x= r~cos\theta$ and $y= r~sin\theta$

The bivariate normal density gives the mass at a point in 2-space. The Rayleigh density gives the mass on a circle in 2-space.

3. Aug 9, 2018

### rabbed

Nevermind, I think I figured it out:
X_PDF(x)*Y_PDF(y) = R_PDF(r)*V_PDF(v) / |J|
Where R is the radius and V is the angle, right? |J| is the Jacobian

4. Aug 9, 2018

### tnich

Not quite. You need to include the differential areas to get equality, not just the determinant of the Jacobian.

5. Aug 9, 2018

### rabbed

Isn't that just if I want to equate the probabilities?
Now I'm just interested in having one joint density equal to another?
The differential areas should cancel out to be the same anyway, I guess

6. Aug 9, 2018

### rabbed

I think my main problem is to know when to use the Jacobian or not, whether it's when integrating or when equating one thing to another.
It's when I've done a change of variables by myself?

7. Aug 9, 2018

### tnich

I was trying to give you one concept that you could use to figure out the answers to all of those questions. Start with a cdf $P(x,y)$ and look at $d^2P(x,y)$.

For the bivariate normal
$d^2P(x,y) = \frac {exp \{-\frac {x^2 + y^2} {2 \sigma^2}\}}{2\pi \sigma^2}~dx~dy$.

If you convert to polar coordinates you get

$d^2P(r,\theta) = \frac 1 {\sigma^2} e\{-\frac {r^2}{2 \sigma^2}\}~r~dr~d\theta = \frac 1 {\sigma^2} e\{-\frac {r^2}{2 \sigma^2}\}~\frac 1 {|J|}~dr~d\theta$.

These two expressions for $d^2P$ are equal. You can see by substitution that
$\frac {exp \{-\frac {x^2 + y^2} {2 \sigma^2}\}}{2\pi \sigma^2} = \frac 1 {\sigma^2} e\{-\frac {r^2}{2 \sigma^2}\}$.

$|J| = 1/r$ is ratio of the two differential areas, so $r~dr~d\theta = dx~dy$. So $d^2P(r,\theta) = d^2P(x,y)$. These are the integrands for the two different coordinate systems. You can easily solve them for the density functions

$\frac {d^2P(r,\theta)} {dr~d\theta}$ and $\frac {d^2P(x,y)} {dx~dy}$

8. Aug 9, 2018

### rabbed

Got it,
thank you!

9. Aug 11, 2018

### rabbed

Back again.. So in essence, in 2D:

X_PDF(x)*Y_PDF(y)*dx*dy = R_PDF(r)*A_PDF(a)*dr*da
X_PDF(x)*Y_PDF(y)*dx*dy = R_PDF(r)*A_PDF(a)*dx*dy / |J|
X_PDF(x)*Y_PDF(y) = R_PDF(r)*A_PDF(a) / |r|
1/sqrt(2*pi)*e^(-x^2/2) * 1/sqrt(2*pi)*e^(-y^2/2) = r*e^(-r^2/2) * 1/(2*pi) / |r|
1/(2*pi)*e^(-(x^2+y^2)/2) = e^(-r^2/2) * 1/(2*pi)

Can you say that:
The normal distribution is the only class of distributions that,
for each independent component in an n-dimensional vector as parameter to the distribution,
can be joined and give the same result as for that vector's length as parameter
(in turn joined with the uniform direction distribution(s) of that n-dimensional vector
and divided by the determinant of the Jacobian of the transformation)?

And that:
An n-dimensional vector having components coming from a normal distribution
will not have it's length being distributed from a normal distribution, but instead
from an n-dimensional Rayleigh distribution?

I guess there is no distribution that you can draw radii from that, combined with
a uniform direction, will give the same distribution for the components of the point, then?
Something is bothering me here.. :)

I want to connect this with the velocity distribution of an ideal gas..

Last edited: Aug 11, 2018
10. Aug 11, 2018

### tnich

A Rayleigh distribution is a special case and is only defined for two dimensions. For three dimensions, you can use a chi-square distribution with three degrees of freedom, which is the distribution of the sum squared of three normal random variables.

The meanings of these questions are not clear. It is often difficult to describe mathematical concepts with words. If you try writing them using mathematical notation, you might come to a clearer understanding of the questions, and be able to answer them.

11. Aug 11, 2018

### rabbed

Okay, before I found out about the Rayleigh distribution I was under the impression that in the derivation of the Maxwell velocity distribution of an ideal gas particle, one wants to find a distribution such that you should be able to draw from this distribution either an X-coordinate, Y-coordinate or radius, and the vectors created (no matter if they are created with an X and Y-coordinate or a radius, all from this distribution) would be distributed the same. Does it make sense?

I tried to find such a distribution:

Transformation function of the random variables X and Y which we want to find out PDF's for:
X = R*cos(A)
Y = R*sin(A)

Known PDF's:
R_PDF(r) = 1/(2*pi*r)*e^(-r^2/2) <-- this is the distribution i meant
A_PDF(a) = 1/(2*pi)

Jacobian (determinant) of the transformation function:
|J| = r

XY_PDF(x,y) =
R_PDF(r) * A_PDF(a) / |J| =
1/(2*pi*r)*e^(-r^2/2) * 1/(2*pi) / r =
1/(2*pi*r)^2*e^(-r^2/2) =
1/(2*pi*sqrt(x^2+y^2))*e^(-x^2/2) * 1/(2*pi*sqrt(x^2+y^2))*e^(-y^2/2) =
X_PDF(x)*Y_PDF(y)

With the distribution R_PDF(r) we get that R_PDF(k) = X_PDF(k) = Y_PDF(k), correct?

Hm, sqrt(x^2+y^2) in X_PDF(x) and Y_PDF(y) as well as the denominator r in R_PDF(r) should probably all be renamed L or something..

Last edited: Aug 11, 2018
12. Aug 12, 2018

### tnich

This is not correct. Rayleigh pdf is
$f(r) = \frac r {\sigma^2}~exp(-\frac {r^2} {2 \sigma^2})$
It should have no $2\pi$ and it should have $r$ in the numerator, not the denominator. You have propagated additional errors from this one.

It sounds like you want to draw random random vectors from a bivariate normal distribution for use in a simulation. This is equivalent to generating a random radius using a Rayleigh distribution and a random angle from a uniform distribution. To make this work, though, you need to use the inverse of the cdf of the Rayleigh distribution. Using this method and two pseudo-random numbers $U_1$ and $U_2$ generated from a uniform distribution, your bivariate normal random vectors will be

$X = Rcos(\theta) \nonumber \\ Y = Rsin(\theta)$

where

$R = F^{-1}(U_1)$
$\theta = 2\pi U_2$

and cdf of R is

$F(r) = 1- exp(-\frac {r^2} {2 \sigma^2})$

Unfortunately, this does not work well in three dimensions because the Rayleigh distribution does not have a convenient three-dimensional analog with an analytical cdf. Instead, you might try generating three gaussian pseudo-random numbers using an inverse error function. You will need to scale the results using a factor of $\sqrt 2 \sigma$.

13. Aug 12, 2018

### rabbed

My problem with the Rayleigh distribution for the radius is that it will not give the x- and y-coordinates also a Rayleigh distribution.
Shouldn’t Isotropy require that both x, y and radius has the same distribution?

14. Aug 12, 2018

### rabbed

Maybe I see my mistake now. It’s the length of the complete vector that should have the same distribution, no matter if you create the vector from two random cartesian components or with a random radius (and uniform direction).
As opposed to my failed intuition, that the components and the radius need to have the same distribution.

15. Aug 12, 2018

### tnich

I think you understand it now.

16. Aug 12, 2018

### rabbed

It would however be interesting to see if there is such a distribution that I thought about.
Like a fundamental distribution for all numbers or something :)
Or is such a distribution impossible? I wasnt able to integrate and invert the one I found

17. Aug 18, 2018

### rabbed

Still struggling to define what has been found..
Can you express it like this:
For an n-dimensional vector - if all vector components should come from some distribution f(x),
then for the vector direction distribution to become uniform, there is only one class of functions
which will do the job: f(x) = sqrt(c/pi)*e^(-c*x^2) for any positive real number c?
The standard normal distribution is a special case, where c = 1/2?