Library for accurate statistical calculations using Python.
Project description
Python Probabilities 🐍
Library for accurate statistical calculations using Python.
Binomial Distributions
Binomial Probability Distribution
If a random variable X
has the binomial distribution B(n, p)
, then its probability mass function can be calculated via Bpd(r, n, p)
.
(where r
is the number of successes, n
is the number of trials, and p
is the probability of success)
The code below would be to calculate P(X=7)
for the binomial distribution X~B(11, 0.33)
.
>>> from python_probabilities import Bpd
>>> Bpd(7, 11, 0.33)
0.0283407102416171981610
Binomial Cumulative Distribution
For the binomial distribution X~B(n, p)
, the cumulative probability function can be calculated via Bcd(r, n, p)
.
(where r
is the number of successes, n
is the number of trials, and p
is the probability of success)
The code below would be to calculate P(X≤7)
for the binomial distribution X~B(11, 0.33)
.
>>> from python_probabilities import Bcd
>>> Bcd(7, 11, 0.33)
0.9917567634324003237640
"A cumulative probability function for a random variable X tells you the sum of all the individual probabilities up to and including the given value of x in the calculation for P(X < x)".
Inverse Binomial Cumulative Distribution
Given the probability for a cumulative probability function, the value for r
(number of successes) can be calculated via InvB(x, n, p)
.
(where x
is the probability, n
is the number of trials, and p
is the probability of success)
>>> from python_probabilities import *
>>> InvB(0.9917567634, 11, 0.33)
7
>>> Bcd(7, 11, 0.33)
0.9917567634324003237640
Poisson Distributions
Poisson Probability Distribution
If a random variable X
has the poisson distribution Po(λ)
, then its probability mass function can be calculated via Ppd(k, λ)
.
(where k
is the number of occurrences and λ
is the expected number of occurrences)
The code below would be to calculate P(X=3)
for the binomial distribution X~Po(6)
.
>>> from python_probabilities import Ppd
>>> Ppd(3, 6)
0.08923507835998894
Poisson Cumulative Distribution
For the binomial distribution X~Po(λ)
, the cumulative probability function can be calculated via Pcd(k, λ)
.
(where k
is the number of occurrences and λ
is the expected number of occurrences)
The code below would be to calculate P(X≤3)
for the binomial distribution X~Po(6)
.
>>> from python_probabilities import Pcd
>>> Pcd(3, 6)
0.15120388277664792
"A cumulative probability function for a random variable X tells you the sum of all the individual probabilities up to and including the given value of x in the calculation for P(X < x)".
Inverse Poisson Cumulative Distribution
Given the probability for a cumulative probability function, the value for k
(number of occurrences) can be calculated via InvP(x, λ)
.
(where x
is the probability and λ
is the expected number of occurrences)
>>> from python_probabilities import *
>>> InvP(0.4, 8)
7
>>> Pcd(7, 8)
0.4529608094869947
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
Hashes for python_probabilities-0.3.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bc9466ccb26b95596e75f79aff87adf7bed8a4b94ebfaf7f2b13cbfb34879e2 |
|
MD5 | fc95b6e76bc7d3dc517dfda7583356a9 |
|
BLAKE2b-256 | 0f20db4ee0646e8b2a34c9baa935ef1c2d2236a064301955cfd8d1da1d462164 |
Hashes for python_probabilities-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | daea80826b709893140bf86572cacc37d246857d507265e5a3d24249b112d94a |
|
MD5 | 6a2374c227a573e58a12739f3491d575 |
|
BLAKE2b-256 | eb860ee956c52620b96f6ed83a29bda953d67016eb8e1a4f23017ee24eb78977 |