Visualize degrees of freedom and critical regions.
The Chi-Square distribution with $k$ degrees of freedom is the distribution of a sum of the squares of $k$ independent standard normal random variables. It is a fundamental distribution in statistical inference, used primarily in hypothesis testing (Goodness of Fit, Test of Independence).
For $x > 0$ and $k > 0$. $\Gamma(\cdot)$ represents the Gamma function.
1. Additivity: If $X \sim \chi^2(k_1)$ and $Y \sim \chi^2(k_2)$ are independent, then $X+Y \sim \chi^2(k_1 + k_2)$.
2. Relation to Normal: As $k \to \infty$, the distribution converges to a Normal distribution (Central Limit Theorem).
3. Relation to F-Test: The ratio of two independent Chi-square variables divided by their degrees of freedom follows an F-distribution.
import scipy.stats as stats
df = 5 # Degrees of freedom
x = 11.07
# 1. Calculate P-Value (Right Tail Area)
# P(X > x) = 1 - CDF(x)
p_val = 1 - stats.chi2.cdf(x, df)
print(f"P-Value (Right Tail) = {p_val:.4f}")
# 2. Find Critical Value from Alpha
# Find x such that P(X > x) = 0.05
alpha = 0.05
crit_val = stats.chi2.ppf(1 - alpha, df)
print(f"Critical Value for alpha {alpha} = {crit_val:.4f}")