Lets call X~N(0,1)
I can't understand why squaring normal random variable outputs a chi-square variable with one degree of freedom.
The problem might be I ignore the intuition behind de the multiplication of two dependent random variables (X*X, X time its self).
I tried to find that intuition programming with python but I can't obtain the chi-squared pdf by squaring the N(0,1) pdf
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as stats
domain = np.arange(-10, 10, 0.001)
X = stats.norm.pdf(domain, 0, 1)
plt.plot(domain**2, X)
plt.plot(domain, X**2)
plt.plot(domain**2, X**2)
plt.show()
I get to think I don’t understand the essence of random variable. If anyone could help me I’d appreciate it. Thanks in advance.
Let $P(x)$ be the probability distribution of a random variable $x$. This means that the probability that $x$ lies in the interval $(a,b)$ is equal to $\int_a^bP(x)dx$. Ok?
Now let $y(x)$ be a function of $x$, and we want to know what is the probability distribution of $y$. Let $Q(y)$ be this function. Let us assume for simplicity that $y(x)$ is injective: there is only one $y$ for each $x$.
So intuitively we expect that the chance of $y$ having the value $y_0$ should be the same as the chance of $x$ having the value $x_0$ such that $y_0=y(x_0)$. Yes?
More concretely, the important identity is $$\int_a^bP(x)dx=\int_{y(a)}^{y(b)}Q(y)dy$$ Now let $b\to a$ to get $$Q(y)\lim_{b\to a}\frac{y(b)-y(a)}{b-a}=Q(y)\frac{dy}{dx}=P(x).$$
This will tell you $Q(y)$ from $P(x)$.
If $x$ has a normal distribution, what is the distribution of $y=x^2$?