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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chi2sim-1.0.2.3.tar.gz.
File metadata
- Download URL: chi2sim-1.0.2.3.tar.gz
- Upload date:
- Size: 72.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac7f22837c56d8e0572b9338be4cdc566ecc8f10a16cd1c6926d4677d0d7a491
|
|
| MD5 |
36bbd2916a4a56a406a590b2c2a48377
|
|
| BLAKE2b-256 |
a9bd97445e76803142507bfe17e993d79af1dc181d9ca46d216657c2a2575c94
|
File details
Details for the file chi2sim-1.0.2.3-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: chi2sim-1.0.2.3-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84d185cda051e5d3b90b7593e77d9803ca453b4d77cf8817e37efbea488a74ab
|
|
| MD5 |
7dd91da640b75f5ce21c8f6fa2495667
|
|
| BLAKE2b-256 |
0746f372f9bd77016d8a5440f84fa859a8497bf520c5f694f39f34d34a676278
|