4
$\begingroup$

When I tried to find this Rayleigh distribution Mathematica couldn't come with an answer:

PDF[TransformedDistribution[
  Sqrt[x1^2 + x2^2], {x1 \[Distributed] 
    NormalDistribution[μ1, σ], 
   x2 \[Distributed] NormalDistribution[μ2, σ]}, 
  Assumptions -> μ1 == μ2 == 0], r]

I want to derive the Rayleigh distribution in parametric form. Mathematica could solve this for N~[0,1] and the answer is Rayleigh[1], but for N~[0,k] it has no answer.

$\endgroup$
5
  • 2
    $\begingroup$ Why not to use the RayleighDistribution? $\endgroup$
    – m0nhawk
    Commented Apr 11, 2015 at 15:37
  • 3
    $\begingroup$ Well, computer algebra systems can't solve every problem you throw at them. Questions like "why can't Mathematica solve it" are not a very good fit here usually. If the question is "how to compute this", then the anwser is what m0nhawk said. $\endgroup$
    – Szabolcs
    Commented Apr 11, 2015 at 15:38
  • 4
    $\begingroup$ @Szabolcs My shrink used to answer all my questions like that. $\endgroup$ Commented Apr 11, 2015 at 15:42
  • 1
    $\begingroup$ @OP What is your question? $\endgroup$
    – shrx
    Commented Apr 11, 2015 at 18:11
  • $\begingroup$ My Question is how Can I Solve this using Mathematica Mathematica Solve this Problem for Normal Distribution ~ [0,1] and returns RayleighDistribution[1] but for Normal Distribution~[0,k] has no Answer!!! $\endgroup$
    – Hamid reza
    Commented Apr 12, 2015 at 6:05

2 Answers 2

5
$\begingroup$

You can use BinormalDistribution instead of two univariate normal distributions:

TransformedDistribution[Sqrt[x1^2 + x2^2],
 {x1, x2} ~Distributed~ BinormalDistribution[{0, 0}, {σ, σ}, 0]]
(* RayleighDistribution[σ] *)

TransformedDistribution[Sqrt[x1^2 + x2^2],
  {x1, x2} ~Distributed~ BinormalDistribution[{m, m}, {σ, σ}, 0]]
(* RiceDistribution[Sqrt[2] m, σ] *)

TransformedDistribution[Sqrt[x1^2 + x2^2],
 {x1, x2 } ~Distributed~ BinormalDistribution[{m1, m2}, {σ1, σ2}, 0]]
(* BeckmannDistribution[m1, m2, σ1, σ2, 0] *)
$\endgroup$
1
  • $\begingroup$ Thanks a lot @Simon! This Solution is very better!!! $\endgroup$
    – Hamid reza
    Commented Apr 12, 2015 at 12:50
9
$\begingroup$

You can get the desired result in two steps:

d1 = TransformedDistribution[x1^2 + x2^2, 
      {Distributed[x1, NormalDistribution[0, σ]], 
       Distributed[x2, NormalDistribution[0, σ]]}]
(* ExponentialDistribution[1/(2 σ^2)] *)

d2 = TransformedDistribution[Sqrt[z], Distributed[z, d1]]
(* RayleighDistribution[σ] *)

PDF[d2,r]

$\begin{cases} \frac{r e^{-\frac{r^2}{2 \sigma ^2}}}{\sigma ^2} & r>0 \\ 0 & \text{True} \end{cases}$

You can also fold the two steps into a single step:

With[{d1 =TransformedDistribution[x1^2 + x2^2, 
     {Distributed[x1, NormalDistribution[0, σ]], 
      Distributed[x2, NormalDistribution[0, σ]]}]}, 
TransformedDistribution[Sqrt[z], Distributed[z, d1]]]
(*  RayleighDistribution[σ] *)

Update: The results above are obtained in Version 9.0.1.0. As noted by @m0nhawk in the comments, in version 10, TransformedDistribution[Sqrt[z], Distributed[z, d1]] gives the result

WeibullDistribution[2, Sqrt[2] σ]

which is equivalent to RayleighDistribution[σ]:

PDF[WeibullDistribution[2, Sqrt[2] σ], r] == PDF[d2, r]
(* True *)
$\endgroup$
9
  • $\begingroup$ I'm getting WeibullDistribution[2, Sqrt[2]/Sqrt[1/\[Sigma]^2]] for d2. Mathematica 10.1. $\endgroup$
    – m0nhawk
    Commented Apr 12, 2015 at 9:51
  • $\begingroup$ @m0nhawk, interesting. I am using v9.0.1.0. Btw, WeibullDistribution[2, Sqrt[2] σ] is equivalent to RayleighDistribution[σ]. $\endgroup$
    – kglr
    Commented Apr 12, 2015 at 9:57
  • $\begingroup$ Yeah, I know, I just provide a usefull information that other Mathematica version have other output. $\endgroup$
    – m0nhawk
    Commented Apr 12, 2015 at 9:58
  • $\begingroup$ @m0nhawk, thank you. Updated with a note on the version 10 output. $\endgroup$
    – kglr
    Commented Apr 12, 2015 at 10:04
  • $\begingroup$ Mathematica Should do this Automatically but didn't! is This a Bug? $\endgroup$
    – Hamid reza
    Commented Apr 12, 2015 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.