Package: promethium
Promethium 🐍Library for calculating statistical distributions, written in pure Python with zero dependencies.Contribution:CONTRIBUTING.mdDocumentation:README.mdDocumentationBinomial DistributionProbability mass functionCumulative distribution functionInverse cumulative distribution functionChi-Squared DistributionProbability density functionCumulative distribution functionNormal DistributionProbability density functionCumulative distribution functionInverse cumulative distribution functionPoisson DistributionProbability mass functionCumulative distribution functionInverse cumulative distributionGeometric DistributionProbability mass functionCumulative distribution functionInverse cumulative distribution functionBinomial DistributionProbability mass functionbinomial.pmf(r,n,p)For the random variableXwith the binomial distributionB(n, p), calculate theprobability mass function.Whereris the number of successes,nis the number of trials, andpis the probability of success.ExampleTo calculateP(X=7)for the binomial distributionX~B(11, 0.33):>>>frompromethiumimportbinomial>>>binomial.pmf(7,11,0.33)0.029656979029412885Cumulative distribution functionbinomial.cdf(r,n,p)For the random variableXwith the binomial distributionB(n, p), calculate thecumulative distribution function.Whereris the number of successes,nis the number of trials, andpis the probability of success.ExampleTo calculateP(X≤7)for the binomial distributionX~B(11, 0.33):>>>frompromethiumimportbinomial.cdf>>>binomial.cdf(7,11,0.33)0.9912362670526581Inverse cumulative distribution functionbinomial.ppf(q,n,p)For the random variableXwith the binomial distributionB(n, p), calculate theinversefor thecumulative distribution function.Whereqis the cumulative probability,nis the number of trials, andpis the probability of success.binomial.ppf(q, n, p)returns the smallest integerxsuch thatbinomial.cdf(x, n, p)is greater than or equal toq.ExampleTo calculate the corresponding value forr(the number of successes) given the value forq(the cumulative probability):>>>frompromethiumimportbinomial>>>binomial.ppf(0.9912362670526581,11,0.333)7>>>binomial.cdf(7,11,0.333)0.9912362670526581Chi-Squared DistributionProbability density functionchi2.pdf(x,df)Probability density function for the chi-squared distributionX~X²(df),
wheredfis the degrees of the freedom.Cumulative distribution functionchi2.cdf(x,df)Cumulative distribution function for the chi-squared distributionX~X²(df),
wheredfis the degrees of the freedom.ExampleTo calculateP(0≤X≤0.556)for the chi-squared distributionX~X²(3):>>>frompromethiumimportchi2>>>chi2.cdf(0.556,3)0.09357297231516998Normal DistributionProbability density functionnormal.pdf(x,µ,σ)Probability density function for the normal distributionX~N(µ, σ).Whereµis the mean, andσis the standard deviation.Cumulative distribution functionnormal.cdf(x,µ,σ)Cumulative distribution function for the normal distributionX~N(µ, σ).Whereµis the mean, andσis the standard deviation.ExampleTo calculateP(X≤0.891)for the normal distributionX~N(0.734, 0.114):>>>frompromethiumimportnormal>>>normal.cdf(0.891,0.734,0.114)0.9157737045522477Inverse cumulative distribution functionnormal.ppf(y,µ,σ)Inverse cumulative distribution function for the normal distributionX~N(µ, σ).Whereµis the mean, andσis the standard deviation.normal.ppf(y, µ, σ)returns the smallest integerxsuch thatnormal.cdf(x, µ, σ)is greater than or equal toy.ExampleTo calculate the corresponding value forxgiven the value fory:>>>frompromethiumimportnormal>>>normal.ppf(0.9157737045522477,0.734,0.114)0.891>>>normal.cdf(0.891,0.734,0.114)0.9157737045522477Poisson DistributionProbability mass functionpoisson.pmf(r,m)For the random variableXwith the poisson distributionPo(m), calculate theprobability mass function.Whereris the number of occurrences, andmis the mean rate of occurrence.ExampleTo calculateP(X=7)for the poisson distributionX~Po(11.556):>>>frompromethiumimportpoisson>>>poisson(11,23.445)0.0019380401123575617Cumulative distribution functionpoisson.cdf(r,m)For the random variableXwith the poisson distributionPo(m), calculate thecumulative distribution function.Whereris the number of occurrences, andmis the mean rate of occurrence.ExampleTo calculateP(X≤7)for the poisson distributionX~Po(11.556):>>>frompromethiumimportpoisson>>>poisson.cdf(11,23.445)0.0034549033698374467Inverse cumulative distributionpoisson.ppf(q,m)For the random variableXwith the poisson distributionPo(m), calculate theinversefor thecumulative distribution function.Whereqis the cumulative probability, andmis the mean rate of occurrence.poisson.ppf(q, m)returns the smallest integerxsuch thatpoisson.cdf(x, m)is greater than or equal toq.ExampleTo calculate the corresponding value forr(number of occurrences) given the values forq(cumulative probability):>>>frompromethiumimportpoisson>>>poisson.ppf(0.0034549033698374467,23.445)11>>>poisson.cdf(11,23.445)0.0034549033698374467Geometric DistributionProbability mass functiongeometric.pmf(x,p)Probability mass function for the geometric distributionX~G(p).Wherexis the number of trials before the first success, andpis the probability of success.ExampleTo calculateP(X=3)for the geometric distributionX~G(0.491):>>>frompromethiumimportgeometric>>>geometric.pmf(3,0.491)0.127208771Cumulative distribution functiongeometric.cdf(x,p)Cumulative distribution function for the geometric distributionX~G(p).Wherexis the number of trials before the first success, andpis the probability of success.ExampleTo calculateP(X≤3)for the geometric distributionX~G(0.491):>>>frompromethiumimportgeometric>>>geometric.cdf(3,0.491)0.868127771Inverse cumulative distribution functiongeometric.ppf(area,p)Inverse cumulative distribution function for the geometric distributionX~G(p).Wherexis the number of trials before the first success, andpis the probability of success.geometric.ppf(area, p)returns the smallest integerxsuch thatgeometric.cdf(x, p)is greater than or equal toarea.ExampleTo calculate the corresponding value forxgiven the value forarea:>>>frompromethiumimportgeometric>>>geometric.ppf(0.868,0.491)3>>geometric.cdf(3,0.491)0.868127771