1

Let $X \sim U(-1, 1)$ and $X \sim U(-1,1)$. We want to find density function of $W = \sqrt{X^2 + Y^2}$.

I got stuck and I have no idea, where I am making a mistake. This is my approach.

Let $F$ be a cumulative distribution function of $W = \sqrt{X^2 + Y^2}$

\begin{align*} F(w) = P(W \le w ) &= P(\sqrt{X^2 + Y^2} \le w) \\ &= P(X^2 + Y^2 \le w^2) \\ &= \iint \limits_{x^2 + y^2 \le w^2} \frac{1}{4} dxdy \\ &= \int \limits_{0}^{w^2} \int \limits_{0}^{2 \pi} \frac{1}{4} d\theta dr \\ &= \pi \frac{w^4}{4} \end{align*} So, the density: $$ f(w) = F'(w) = \pi w^3 $$

But if I run a simulation:

X <- runif(100000, -1, 1)
Y <- runif(100000, -1, 1)
R2 <- X^2 + Y^2
R <- sqrt(R2)

hist(R,  prob=TRUE)

enter image description here

Where am I making a mistake?

Xi'an
  • 90,397
  • 9
  • 157
  • 575
Elizabeth_Banks
  • 261
  • 1
  • 6
  • 1
    Closely related questions include https://stats.stackexchange.com/questions/28658 and https://stats.stackexchange.com/questions/52909. – whuber Jun 12 '20 at 13:16
  • 1
    This looks exactly like https://stats.stackexchange.com/q/323617/119261. – StubbornAtom Jun 12 '20 at 15:05

1 Answers1

2

Some observations:

  • The radius is $w$, but you're taking it as $w^2$
  • Don't forget the $|J|$ term (i.e. $rdrd\theta$) in the integral (or you can simply use area of the circle as well)
  • The density will take two different functional forms for $[0,1]$ and $[1,\sqrt{2}]$. Visualise a growing circle inside the square $[-1,1]\times[-1,1]$.
gunes
  • 49,700
  • 3
  • 39
  • 75
  • Thanks! for $[0,1]$ calculations are easy and I was able to receive the good result. Will it be correct if for $[1, \sqrt{2}]$ I would consider one quater and write $\int_0^1 \int_0^{\sqrt{w^2 -1}} \frac{1}{4} dx dy + \int_{\sqrt{w^2 -1}}^1 \int_0^{\sqrt{w^2 - x^2}} \frac{1}{4} dydx$ and then multiply the result by 4? – Elizabeth_Banks Jun 12 '20 at 12:17
  • I might be mistaken but the integral didn't seem correct. Why don't you calculate using just the formulas for area and then try to verify your integrals? – gunes Jun 12 '20 at 13:03