chi-squared-test

A simple function for calculating the chi-squared probability for a given observation set and expected set"

Last updated 6 years ago by
chipbell4 .

MIT ·
Repository ·
Bugs ·
Original npm ·
Tarball ·
package.json
$ cnpm install chi-squared-test

SYNC missed versions from
official npm registry.

This package provides a small function for calculating a chi-squared test on a given dataset. Given an observed set of frequencies `observations`

, an expected set of frequencies `expectations`

, and the number of degrees of freedom reduced in the measurement, calculates the probability that the observations came from the same probability distribution.

For example, let's check a die for fairness:

```
var chiSquaredTest = require('chi-squared-test');
// We expect a fair die
var expected = [2, 2, 2, 2, 2, 2];
// Looks pretty unfair...
var observed = [6, 3, 3, 0, 0, 0];
// Reduction in degrees of freedom is 1, since knowing 5 categories determines the 6th
var reduction = 1;
var probability = chiSquaredTest(observed, expected, reduction);
// Gives 0.010362, which indicates that it's unlikely the die is fair
// However, something a little more likely
observed = [1, 2, 4, 4, 2, 1];
probability = chiSquaredTest(observed, expected, reduction);
// Gives back 0.415881, which is indicates that they did come from the same distribution (by most statistical standards)
```

- 1.1.0 ... latest (6 years ago)

Maintainers (1)

Downloads

Today
0

This Week
0

This Month
0

Last Day
0

Last Week
0

Last Month
0

Dependencies (1)

- chi-squared ^1.1.0

Dev Dependencies (0)

None
Dependents (1)

Copyright 2014 - 2016 © taobao.org |