New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

chi-squared-test

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chi-squared-test

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

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Chi-Squared Test

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)

Keywords

FAQs

Package last updated on 29 Jan 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc