Skip to content

KeisukeNagakawa/cisim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Confidence Interval of Hypergeometric Distribution Simulation Module

For a hypergeometric distribution, denoted by Hyper(n_pop, k_s, n_draw), where n_pop is the population size, k_s is the number of population with 'success', and n_draw is the given sample size, this program calculates the confidence interval for k_s when n_pop is known and number of observed success is given as k_s_obs, using simulation scipy optimization tools.

Note that this is done by a simulation and can have unaccurate values as a solution. Please cross-check with other site calculating confidence interval of hypergeometric function like here: cluster-text.com.

PyPI package link is here.


First, pip install this package.

shell

pip install cisim

Note: if this installing doesn't go well, please try pip install these packages: cerberus, numpy, and scipy.

After the pip-install, you can calculate the interval of a Hypergeometric distribution as follows.

python

import cisim
from cisim.stats import HyperCI
h = HyperCI(n_pop=10**4, n_draw=10**3, k_s_obs=100)
res = h.ci_sim()
print(res[0])
>>> [830, 1193]

And this program can also calculate confidence interaval for binomial distribution, too.

import cisim
from cisim.stats import BinomCI
b = BinomCI(n_pop=100, n_obs=10, cl=0.05)
res = b.ci_sim()
print(res[0])
>>> [0.049005430267763495, 0.17622473596973592]

You can check and compare the result with Clopper-Pearson approach on cluster-text.com

Learn more at HyperGeometric distribution, Binomial Distribution


If you want to learn more about setup.py files, check out this repository.

About

Hypegeometric confidence interval calculator.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published