官术网_书友最值得收藏!

The chi-square distribution

The chi-square statistics are defined by the following formula:

The chi-square distribution

Here, n is the size of the sample, s is the standard deviation of the sample, and σ is the standard deviation of the population.

If we repeatedly take samples and define the chi-square statistics, then we can form a chi-square distribution, which is defined by the following probability density function:

The chi-square distribution

Here, Y0 is a constant that depends on the number of degrees of freedom, Χ2 is the chi-square statistic, v = n - 1 is the number of degrees of freedom, and e is a constant equal to the base of the natural logarithm system.

Y0 is defined so that the area under the chi-square curve is equal to one.

The chi-square distribution

Chi-square for the goodness of fit

The Chi-square test can be used to test whether the observed data differs significantly from the expected data. Let's take the example of a dice. The dice is rolled 36 times and the probability that each face should turn upwards is 1/6. So, the expected distribution is as follows:

>>> expected = np.array([6,6,6,6,6,6])

The observed distribution is as follows:

>>> observed = observed = np.array([7, 5, 3, 9, 6, 6])

The null hypothesis in the chi-square test is that the observed value is similar to the expected value.

The chi-square can be performed using the chisquare function in the SciPy package:

>>> stats.chisquare(observed,expected)
(3.333333333333333, 0.64874235866759344)

The first value is the chi-square value and the second value is the p-value, which is very high. This means that the null hypothesis is valid and the observed value is similar to the expected value.

主站蜘蛛池模板: 北宁市| 北辰区| 邛崃市| 武陟县| 扬中市| 宣威市| 专栏| 榆社县| 新乐市| 南汇区| 榆中县| 自治县| 南阳市| 共和县| 石河子市| 南投市| 临漳县| 泊头市| 惠东县| 瑞金市| 浦东新区| 靖西县| 普格县| 思茅市| 社会| 平南县| 鲁甸县| 华安县| 峨边| 海原县| 连云港市| 武乡县| 桦南县| 江津市| 那曲县| 水城县| 五家渠市| 芦溪县| 洪湖市| 鄯善县| 大足县|