keisoku

Chi-Square Distribution Random Generator

Generate random numbers from a chi-square distribution by setting degrees of freedom k and a sample size. Shows the sample mean, variance, and a histogram.

Input

Enter the degrees of freedom k and how many values to draw, then press the button to generate random numbers from a chi-square distribution.

df

An integer of 1 or more is recommended (1 to 1000)

values

Up to 10000 values

Result

Enter the degrees of freedom and sample size, then press the button to see the results here.

How it works

  • A chi-square distribution with k degrees of freedom is the sum of the squares of k independent standard normal variables.
  • For small integer degrees of freedom the generator sums squared standard normals directly; otherwise it uses the fact that the distribution equals Gamma(k/2, 2) and samples it with the Marsaglia-Tsang method.
  • Standard normal values are produced with the Box-Muller transform.
  • The theoretical mean is k and the theoretical variance is 2k. As the sample size grows, the sample mean approaches k and the sample variance approaches 2k.
  • Numbers are generated only when you press the button. The same settings produce different results each time you press it.

Reviews

Tell us what you think of this calculator.

Write a review

  1. Home
  2. Chi-Square Distribution Random Generator