Skip to main content

A small example package

Project description

Montecarlo Library

montecarlo-library is a Python library that contains montecarlo simulations functions used in hyphotesis testing such as:

Permutation Test: Also called re-randomization test is an exact statistical hypothesis test making use of the proof by contradiction. A permutation test involves two or more samples. The null hypothesis is that all samples come from the same distribution {\displaystyle H_{0}:F=G}{\displaystyle H_{0}:F=G}. Under the null hypothesis, the distribution of the test statistic is obtained by calculating all possible values of the test statistic under possible rearrangements of the observed data.

Bootstrap Sample Bootstrapping is any test or metric that uses random sampling with replacement (e.g. mimicking the sampling process), and falls under the broader class of resampling methods. Bootstrapping assigns measures of accuracy (bias, variance, confidence intervals, prediction error, etc.) to sample estimates.[1][2] This technique allows estimation of the sampling distribution of almost any statistic using random sampling methods.[3][4]

Bootstrapping estimates the properties of an estimand (such as its variance) by measuring those properties when sampling from an approximating distribution. One standard choice for an approximating distribution is the empirical distribution function of the observed data. In the case where a set of observations can be assumed to be from an independent and identically distributed population, this can be implemented by constructing a number of resamples with replacement, of the observed data set (and of equal size to the observed data set).

It may also be used for constructing hypothesis tests. It is often used as an alternative to statistical inference based on the assumption of a parametric model when that assumption is in doubt, or where parametric inference is impossible or requires complicated formulas for the calculation of standard errors.

Installation

Use the package manager pip to install montecarlo.

pip install montecarlo

Usage

from montecarlo import hyphotesis_testing

# Generate Bootstrap Sample 
# returns 'list of numbers'
hyphotesis_testing.generate_bootstrap_values(data=list,
                                    estimator=np.median,
                                    sample_size=100,
                                    n_samples=4000,
                                    verbose=True)

# Generate Permutation Samples 
# returns list of values 
data = hyphotesis_testing.generate_permutation_samples(x=values1,
                                    y=values2,
                                    estimator=np.mean,
                                    n_iter=4000)
# Get p-value
# returns a list with the p-value and a bool evaluation value.  
# Example: [0.00024993751562107924, True]
test_val = np.abs(mean diff)
pval = hyphotesis_testing.get_pvalue(test=test_val, data=data)

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

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

montecarlo_library-0.0.1.tar.gz (306.0 kB view hashes)

Uploaded Source

Built Distribution

montecarlo_library-0.0.1-py3-none-any.whl (8.3 kB view hashes)

Uploaded Python 3

Supported by

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