Skip to main content

Chi-square test with Monte Carlo simulation

Project description

chi2sim

Chi-square test with Monte Carlo simulation for contingency tables. The package and its documentation are still under construction.

Description

The chi2sim package is a Python implementation that contains the translation of R's H tests for contingency tables when simulate.p.value = TRUE, originally written in C and based on Patefield's (1981) FORTRAN algorithm. The package provides a fast and reliable method to compute p-values for chi-square tests using Monte Carlo simulation.

Installation

pip install chi2sim

Usage

import numpy as np
from chi2sim import chi2_cont_sim

# Example contingency table
table = np.array([
    [10, 5],
    [20, 15]
], dtype=int)

# Perform chi-square test with Monte Carlo simulation
result = chi2_cont_sim(table)
print(result)

Features

  • Similar to SciPy's scipy.stats.chi2_contingency, but returns
  • Monte Carlo simulation for p-value approximation
  • Easy-to-use Python interface

Requirements

  • Python >= 3.9
  • NumPy >= 1.15.0

License

This project is licensed under the MIT License - see the LICENSE file for details.

Citation

If you use the chi2sim package in your study, please don't forget to cite the following literatures:

  • Hope, A. C. A. (1968). A simplified Monte Carlo significance test procedure. Journal of the Royal Statistical Society Series B, 30, 582–598. doi:10.1111/j.2517-6161.1968.tb00759.x.

  • Patefield, W. M. (1981). Algorithm AS 159: An efficient method of generating r x c tables with given row and column totals. Applied Statistics, 30, 91–97. doi:10.2307/2346669.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chi2sim-1.0.2.2.tar.gz (72.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chi2sim-1.0.2.2-cp311-cp311-win_amd64.whl (100.5 kB view details)

Uploaded CPython 3.11Windows x86-64

File details

Details for the file chi2sim-1.0.2.2.tar.gz.

File metadata

  • Download URL: chi2sim-1.0.2.2.tar.gz
  • Upload date:
  • Size: 72.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.7

File hashes

Hashes for chi2sim-1.0.2.2.tar.gz
Algorithm Hash digest
SHA256 7d2c434a312987b91c73441eec9711ca4fa15cfd257b59c934d69ef494074187
MD5 cb079f907ef940d7d66c2519b8d35e94
BLAKE2b-256 5af46e2a693525ef7ea62d1edb00d07d7ca3c538c4f80e7677963be1f64d58f6

See more details on using hashes here.

File details

Details for the file chi2sim-1.0.2.2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: chi2sim-1.0.2.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 100.5 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.7

File hashes

Hashes for chi2sim-1.0.2.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 511e3660d99880eca86d210c2b24178c73f1d7ecc727b2120e2ba45e9a1244f4
MD5 2df7559703eb9ba28a682c6cee76e086
BLAKE2b-256 b547c1f774ab9b8e3ef91cd2f6305596f0aa57124ed1d10330fa268ea1ae4aba

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page