# Chi-square Distribution

• /
• Blog
• /
• Chi-square Distribution

The chi-square distribution is a continuous probability distribution that describes the distribution of the sum of squares of independent standard normal random variables. It is commonly used in statistical hypothesis testing to evaluate the goodness of fit of a model to a set of data. The chi-square distribution is defined by a single parameter, k, which is the number of degrees of freedom.

## Properties of Chi-Square Distribution:

The chi-square distribution is a continuous probability distribution that is defined by a single parameter called the degrees of freedom. It has several important properties, including:

1. Right-skewed shape: The chi-square distribution is right-skewed, meaning that it has a long tail on the right side of the distribution.
2. Non-negative: The chi-square distribution is always non-negative, since the squared values of random variables can never be negative.
3. Asymptotic behaviour: The chi-square distribution approaches the x-axis as the values of x become increasingly large. This means that the probability of a value being extremely large is always non-zero but becomes increasingly small as the value becomes more extreme.
4. Non-symmetrical: The chi-square distribution is not symmetrically distributed.
5. Use in statistical hypothesis testing: The chi-square distribution is often used in statistical hypothesis testing to determine the goodness of fit of a model to a set of data or to test the independence of two variables.

## Chi-square Statistic

To use the chi-square distribution in statistical hypothesis testing, you need to calculate the chi-square statistic, which measures how well a model fits a data set. The chi-square statistic is calculated by summing the squared differences between the observed values and the expected values, divided by the expected values.

$$\chi^2 = \sum_{i=1}^n \frac{(O_i - E_i)^2}{E_i}$$

where:

n is the number of data points, O is the observed value for each data point, E is the expected value for each data point

## Probability Density Function (PDF):

The probability density function (PDF) of the chi-square distribution is a function that describes the probability of a given value occurring under the distribution. The PDF of the chi-square distribution is defined as:

$$f(x) = \frac{1}{2^{k/2}\Gamma(k/2)} x^{k/2-1} e^{-x/2}$$

where:

$$k$$ is the degrees of freedom

$$\Gamma(k/2)$$ is the gamma function

## Chi-Square Calculator:

Find the area under the Chi-Square Distribution (Left or Right Tail)

 function chi_square_distribution(x, df) { const gamma = math.gamma(df / 2); return (1 / (Math.pow(2, df / 2) * gamma)) * Math.pow(x, (df / 2) - 1) * Math.exp(-x / 2); } function calculateAreaUnderCurve() { const chiValueInput = document.getElementById('chi-value'); const tailSelection = document.getElementById('tail-selection'); const dfInput = document.getElementById('df'); const resultContainer = document.getElementById('result'); const chiValue = parseFloat(chiValueInput.value); const tail = tailSelection.value; const df = parseFloat(dfInput.value); if (isNaN(chiValue)) { alert('Please enter a valid chi-square value.'); return; } if (isNaN(df) || df <= 0) { alert('Please enter a valid degrees of freedom value greater than 0.'); return; } let areaUnderCurve; if (tail === 'left') { areaUnderCurve = jStat.chisquare.cdf(chiValue, df); } else if (tail === 'right') { areaUnderCurve = 1 - jStat.chisquare.cdf(chiValue, df); } drawChiSquareDistributionCurve(chiValue, tail, df); resultContainer.textContent = 'Area Under Curve: ' + areaUnderCurve.toFixed(4); } function calculateChiValue() { const probabilityInput = document.getElementById("probability-input"); const tailSelectionZ = document.getElementById("tail-selection-z"); const dfInputZ = document.getElementById('df-z'); const resultContainerChi = document.getElementById("result-chi"); const probability = parseFloat(probabilityInput.value); const tail = tailSelectionZ.value; const df = parseFloat(dfInputZ.value); if (isNaN(probability) || probability < 0 || probability > 1) { alert('Please enter a valid probability between 0 and 1.'); return; } if (isNaN(df) || df <= 0) { alert('Please enter a valid degrees of freedom value greater than 0.'); return; } let chiValue; if (tail === 'left') { chiValue = jStat.chisquare.inv(probability, df); } else if (tail === 'right') { chiValue = jStat.chisquare.inv(1 - probability, df); } resultContainerChi.textContent = 'Chi-Square Value: ' + chiValue.toFixed(4); drawChiSquareDistributionCurve(chiValue, tail, df); } function drawChiSquareDistributionCurve(chiValue, tail, df) { const maxX = Math.max(20, 2 * df); const x = Array.from({ length: 1000 }, (_, i) => 0 + (i * maxX) / 1000); const y = x.map(xi => chi_square_distribution(xi, df)); let fillX, fillY; if (tail === 'left') { fillX = x.filter(xi => xi <= chiValue); } else if (tail === 'right') { fillX = x.filter(xi => xi >= chiValue); } fillY = fillX.map(xi => chi_square_distribution(xi, df)); const trace1 = { x: x, y: y, mode: 'lines', line: { color: 'blue' }, name: 'Chi-Square Distribution' }; const trace2 = { x: fillX, y: fillY, mode: 'lines', fill: 'tozeroy', line: { color: 'orange' }, name: 'Area Under Curve' }; const data = [trace1, trace2]; const layout = { title: 'Chi-Square Distribution', xaxis: { title: 'Chi-Square Value' }, yaxis: { title: 'Density' }, showlegend: true }; Plotly.newPlot('curve-plot', data, layout); } /* function drawChiSquareDistributionCurve(chiValue, tail, df) { const x = Array.from({ length: 1000 }, (_, i) => 0 + (i * 20) / 1000); const y = x.map(xi => chi_square_distribution(xi, df)); let fillX, fillY; if (tail === 'left') { fillX = x.filter(xi => xi <= chiValue); } else if (tail === 'right') { fillX = x.filter(xi => xi >= chiValue); } fillY = fillX.map(xi => chi_square_distribution(xi, df)); const trace1 = { x: x, y: y, mode: 'lines', line: { color: 'blue' }, name: 'Chi-Square Distribution' }; const trace2 = { x: fillX, y: fillY, mode: 'lines', fill: 'tozeroy', line: { color: 'orange' }, name: 'Area Under Curve' }; const data = [trace1, trace2]; const layout = { title: 'Chi-Square Distribution', xaxis: { title: 'Chi-Square Value' }, yaxis: { title: 'Density' }, showlegend: true }; Plotly.newPlot('curve-plot', data, layout); } */ 

## Mean, Mode and Variance of Chi-square Distribution

Mean: The mean of the chi-square distribution is equal to the degrees of freedom (df).

$$\mu = df$$

Mode: The mode of the chi-square distribution is equal to the degrees of freedom minus 2 (if the degrees of freedom are greater than 2).

$$mode = (df - 2) \text { for df} \geq 2$$

Variance: The variance of the chi-square distribution is equal to twice the degrees of freedom.

$$\sigma^2 = 2 \cdot df$$

Standard deviation: The standard deviation of the chi-square distribution is equal to the square root of twice the degrees of freedom.

$$\sigma = \sqrt{2 \cdot df}$$

These are the mean, mode, standard deviation, and variance of the chi-square distribution. They are all related to the degrees of freedom and can be used to describe the shape and spread of the distribution.

## Using Microsoft Excel

### CHISQ.DIST:

The CHISQ.DIST function in Microsoft Excel calculates the probability density function (PDF) or cumulative distribution function (CDF) of the chi-square distribution. The function has the following syntax:

CHISQ.DIST(x, degrees_freedom, cumulative)

Where:

• x: is the value for which you want to calculate the probability density or cumulative probability.
• degrees_freedom: is the number of degrees of freedom in the chi-square distribution.
• cumulative: is a logical value that specifies whether you want to calculate the PDF (FALSE) or CDF (TRUE) of the chi-square distribution.

The function returns the probability density or cumulative probability of the given value under the chi-square distribution with the specified degrees of freedom.

### CHISQ.INV:

The CHISQ.INV function in Microsoft Excel calculates the inverse of the chi-square distribution for a given probability and degrees of freedom. The function has the following syntax:

CHIINV(probability, degrees_freedom)

where:

• probability: is the probability for which you want to find the corresponding value under the chi-square distribution. This should be a value between 0 and 1.
• degrees_freedom: is the number of degrees of freedom in the chi-square distribution.

The function returns the value of the chi-square statistic corresponding to the given probability and degrees of freedom.

### CHISQ.DIST.RT:

The CHISQ.DIST.RT function in Microsoft Excel calculates the right-tailed probability of the chi-square distribution for a given value and degrees of freedom. The function has the following syntax:

CHISQ.DIST.RT(x, degrees_freedom)

where:

• x: is the value for which you want to calculate the right-tailed probability.
• degrees_freedom: is the number of degrees of freedom in the chi-square distribution.

The function returns the right-tailed probability of the given value under the chi-square distribution with the specified degrees of freedom.

### CHISQ.INV.RT:

The CHISQ.INV.RT function in Microsoft Excel calculates the inverse of the right-tailed probability of the chi-square distribution for a given probability and degrees of freedom. The function has the following syntax:

CHIINV.RT(probability, degrees_freedom)

where:

• probability: is the right-tailed probability for which you want to find the corresponding value under the chi-square distribution. This should be a value between 0 and 1.
• degrees_freedom: is the number of degrees of freedom in the chi-square distribution.

The function returns the value of the chi-square statistic corresponding to the given right-tailed probability and degrees of freedom.

## Conclusion

In conclusion, the chi-square distribution is a probability distribution used in statistical analysis to test the goodness of fit of a model to a set of data and to test the independence of two variables. It is defined by the degrees of freedom.

Posted on December 27, 2022 by  Quality Gurus

## SALE! 4 Most Popular Courses

 (adsbygoogle = window.adsbygoogle || []).push({}); 

###### Quality Gurus

Customers served! 1

Quality Management Course

FREE! Subscribe to get 52 weekly lessons. Every week you get an email that explains a quality concept, provides you with the study resources, test quizzes, tips and special discounts on our other e-learning courses.

 (adsbygoogle = window.adsbygoogle || []).push({}); 

Similar Posts:

September 21, 2022

## Repairable vs Non-repairable Products

Repairable vs Non-repairable Products

December 19, 2022

## What is a Normal Probability Plot?

What is a Normal Probability Plot?

August 28, 2022

## Sustain Improvements in DMAIC Control Phase

Sustain Improvements in DMAIC Control Phase

December 20, 2021

## Inspection Errors

Inspection Errors

June 9, 2022

## ASQ® CSSYB Body of Knowledge 2022 – What is New?

ASQ® CSSYB Body of Knowledge 2022 – What is New?

April 10, 2022

## Statistics, Data Analysis Using MS Excel – Quiz

Statistics, Data Analysis Using MS Excel – Quiz

March 30, 2018

## 5 Key Philosophies Behind Lean

5 Key Philosophies Behind Lean

August 28, 2022

## Implementation Planning and Strategies in DMAIC

Implementation Planning and Strategies in DMAIC

December 25, 2022

## PDF, CDF and PMF – Probability Distribution Functions

PDF, CDF and PMF – Probability Distribution Functions

32 Courses on SALE!