# Density of square root of sum of squared independent uniform random variables [duplicate]

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)


Where am I making a mistake?

• 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]$$.
• 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 at 12:17