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.2.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b170f79ae6a20f73e638152f4cd1bed86bd04565d2ccaa36e981f04ddcd44fec |
|
MD5 | 39f9dd72c6b61e3c65ca34a6315e7aa6 |
|
BLAKE2b-256 | 6a5cabe2a8a4ac6136673285b12e8e76e60312efd74a9552d68cc2a5dbdc2605 |
Hashes for python_probabilities-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b474a092c2a11a4116385b0e87e29ce9a6a7215741432e31724ac5e778f14aa |
|
MD5 | fa7720b1e6c095b655f051389823aea9 |
|
BLAKE2b-256 | 72b795ce533ee50e30d90d57d8e9a8533efb68e2e357e771ab633d33c68fc9e6 |