promethium 0.7.4

Creator: bradpython12

Last updated:

Add to Cart

Description:

promethium 0.7.4

Promethium 🐍


Library for calculating statistical distributions, written in pure Python with zero dependencies.
Contribution: CONTRIBUTING.md
Documentation: README.md

Documentation

Binomial Distribution

Probability mass function
Cumulative distribution function
Inverse cumulative distribution function


Chi-Squared Distribution

Probability density function
Cumulative distribution function


Normal Distribution

Probability density function
Cumulative distribution function
Inverse cumulative distribution function


Poisson Distribution

Probability mass function
Cumulative distribution function
Inverse cumulative distribution


Geometric Distribution

Probability mass function
Cumulative distribution function
Inverse cumulative distribution function




Binomial Distribution
Probability mass function
binomial.pmf(r, n, p)

For the random variable X with the binomial distribution B(n, p), calculate the probability mass function.
Where r is the number of successes, n is the number of trials, and p is the probability of success.
Example
To calculate P(X=7) for the binomial distribution X~B(11, 0.33):
>>> from promethium import binomial
>>> binomial.pmf(7, 11, 0.33)
0.029656979029412885

Cumulative distribution function
binomial.cdf(r, n, p)

For the random variable X with the binomial distribution B(n, p), calculate the cumulative distribution function.
Where r is the number of successes, n is the number of trials, and p is the probability of success.
Example
To calculate P(X≤7) for the binomial distribution X~B(11, 0.33):
>>> from promethium import binomial.cdf
>>> binomial.cdf(7, 11, 0.33)
0.9912362670526581

Inverse cumulative distribution function
binomial.ppf(q, n, p)

For the random variable X with the binomial distribution B(n, p), calculate the inverse for the cumulative distribution function.
Where q is the cumulative probability, n is the number of trials, and p is the probability of success.
binomial.ppf(q, n, p) returns the smallest integer x such that binomial.cdf(x, n, p) is greater than or equal to q.
Example
To calculate the corresponding value for r (the number of successes) given the value for q (the cumulative probability):
>>> from promethium import binomial
>>> binomial.ppf(0.9912362670526581, 11, 0.333)
7
>>> binomial.cdf(7, 11, 0.333)
0.9912362670526581


Chi-Squared Distribution
Probability density function
chi2.pdf(x, df)

Probability density function for the chi-squared distribution X~X²(df),
where df is the degrees of the freedom.
Cumulative distribution function
chi2.cdf(x, df)

Cumulative distribution function for the chi-squared distribution X~X²(df),
where df is the degrees of the freedom.
Example
To calculate P(0≤X≤0.556) for the chi-squared distribution X~X²(3):
>>> from promethium import chi2
>>> chi2.cdf(0.556, 3)
0.09357297231516998


Normal Distribution
Probability density function
normal.pdf(x, µ, σ)

Probability density function for the normal distribution X~N(µ, σ).
Where µ is the mean, and σ is the standard deviation.
Cumulative distribution function
normal.cdf(x, µ, σ)

Cumulative distribution function for the normal distribution X~N(µ, σ).
Where µ is the mean, and σ is the standard deviation.
Example
To calculate P(X≤0.891) for the normal distribution X~N(0.734, 0.114):
>>> from promethium import normal
>>> normal.cdf(0.891, 0.734, 0.114)
0.9157737045522477

Inverse cumulative distribution function
normal.ppf(y, µ, σ)

Inverse cumulative distribution function for the normal distribution X~N(µ, σ).
Where µ is the mean, and σ is the standard deviation.
normal.ppf(y, µ, σ) returns the smallest integer x such that normal.cdf(x, µ, σ) is greater than or equal to y.
Example
To calculate the corresponding value for x given the value for y:
>>> from promethium import normal
>>> normal.ppf(0.9157737045522477, 0.734, 0.114)
0.891
>>> normal.cdf(0.891, 0.734, 0.114)
0.9157737045522477


Poisson Distribution
Probability mass function
poisson.pmf(r, m)

For the random variable X with the poisson distribution Po(m), calculate the probability mass function.
Where r is the number of occurrences, and m is the mean rate of occurrence.
Example
To calculate P(X=7) for the poisson distribution X~Po(11.556):
>>> from promethium import poisson
>>> poisson(11, 23.445)
0.0019380401123575617

Cumulative distribution function
poisson.cdf(r, m)

For the random variable X with the poisson distribution Po(m), calculate the cumulative distribution function.
Where r is the number of occurrences, and m is the mean rate of occurrence.
Example
To calculate P(X≤7) for the poisson distribution X~Po(11.556):
>>> from promethium import poisson
>>> poisson.cdf(11, 23.445)
0.0034549033698374467

Inverse cumulative distribution
poisson.ppf(q, m)

For the random variable X with the poisson distribution Po(m), calculate the inverse for the cumulative distribution function.
Where q is the cumulative probability, and m is the mean rate of occurrence.
poisson.ppf(q, m) returns the smallest integer x such that poisson.cdf(x, m) is greater than or equal to q.
Example
To calculate the corresponding value for r (number of occurrences) given the values for q (cumulative probability):
>>> from promethium import poisson
>>> poisson.ppf(0.0034549033698374467, 23.445)
11
>>> poisson.cdf(11, 23.445)
0.0034549033698374467


Geometric Distribution
Probability mass function
geometric.pmf(x, p)

Probability mass function for the geometric distribution X~G(p).
Where x is the number of trials before the first success, and p is the probability of success.
Example
To calculate P(X=3) for the geometric distribution X~G(0.491):
>>> from promethium import geometric
>>> geometric.pmf(3, 0.491)
0.127208771

Cumulative distribution function
geometric.cdf(x, p)

Cumulative distribution function for the geometric distribution X~G(p).
Where x is the number of trials before the first success, and p is the probability of success.
Example
To calculate P(X≤3) for the geometric distribution X~G(0.491):
>>> from promethium import geometric
>>> geometric.cdf(3, 0.491)
0.868127771

Inverse cumulative distribution function
geometric.ppf(area, p)

Inverse cumulative distribution function for the geometric distribution X~G(p).
Where x is the number of trials before the first success, and p is the probability of success.
geometric.ppf(area, p) returns the smallest integer x such that geometric.cdf(x, p) is greater than or equal to area.
Example
To calculate the corresponding value for x given the value for area:
>>> from promethium import geometric
>>> geometric.ppf(0.868, 0.491)
3
>> geometric.cdf(3, 0.491)
0.868127771

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.