Loading content...
The chi-square distribution (denoted χ²) is one of the most important continuous probability distributions in statistical inference. It plays a pivotal role in hypothesis testing, confidence interval construction, and goodness-of-fit analysis. This distribution arises naturally as the sum of squares of independent standard normal random variables.
Given a sample observation point x and the degrees of freedom parameter k, your task is to compute the probability density function (PDF) value at that point.
The probability density function of the chi-square distribution is defined as:
$$f(x; k) = \frac{1}{2^{k/2} \cdot \Gamma(k/2)} \cdot x^{(k/2) - 1} \cdot e^{-x/2}$$
Where:
The Gamma function is defined as: $$\Gamma(n) = (n-1)!$$ for positive integers
For half-integers: $$\Gamma(1/2) = \sqrt{\pi}$$
More generally: $$\Gamma(n + 1/2) = \frac{(2n-1)!!}{2^n} \sqrt{\pi}$$
Where !! denotes the double factorial.
Implement a function that calculates the probability density of a chi-square distribution at a given observation point x with k degrees of freedom. Return the result rounded to 3 decimal places.
x = 2.0, k = 20.184For a chi-square distribution with k = 2 degrees of freedom, we evaluate the PDF at x = 2:
Step 1: Identify the formula components
Step 2: Apply the formula f(2; 2) = (1 / (2 × 1)) × 1 × 0.3679 f(2; 2) = 0.5 × 0.3679 f(2; 2) ≈ 0.184
The probability density at x = 2 for k = 2 degrees of freedom is approximately 0.184.
Note: When k = 2, the chi-square distribution simplifies to an exponential distribution with rate 0.5.
x = 1.0, k = 10.242For a chi-square distribution with k = 1 degree of freedom, we evaluate the PDF at x = 1:
Step 1: Identify the formula components
Step 2: Apply the formula f(1; 1) = (1 / (1.4142 × 1.7725)) × 1 × 0.6065 f(1; 1) = (1 / 2.5066) × 0.6065 f(1; 1) = 0.3989 × 0.6065 f(1; 1) ≈ 0.242
The probability density at x = 1 for k = 1 degree of freedom is approximately 0.242.
x = 4.0, k = 40.135For a chi-square distribution with k = 4 degrees of freedom, we evaluate the PDF at x = 4:
Step 1: Identify the formula components
Step 2: Apply the formula f(4; 4) = (1 / (4 × 1)) × 4 × 0.1353 f(4; 4) = 0.25 × 4 × 0.1353 f(4; 4) = 1 × 0.1353 f(4; 4) ≈ 0.135
The probability density at x = 4 for k = 4 degrees of freedom is approximately 0.135.
Note: When x equals k (the mean of the distribution), the density value provides insight into the distribution's central tendency.
Constraints