source.discrete package¶
Submodules¶
source.discrete.Finite module¶
- class source.discrete.Finite.Bernoulli(p: float)[source]¶
Bases:
source.discrete.Finite.Finite
This class contains methods concerning the Bernoulli Distribution. Bernoulli Distirbution is a special case of Binomial Distirbution 1 2.
\[\text{Bernoulli} (x;p) = p^n (1-p)^{1-x}\]- Parameters
p (-) -- event of success. Either 0 or 1.
x (-) -- possible outcomes. Either 0 or 1.
References
- 1
Weisstein, Eric W. "Bernoulli Distribution." From MathWorld--A Wolfram Web Resource. https://mathworld.wolfram.com/BernoulliDistribution.html
- 2
Wikipedia contributors. (2020, December 26). Bernoulli distribution. https://en.wikipedia.org/w/index.php?title=Bernoulli_distribution&oldid=996380822
- cdf(x: Union[List[int], int, numpy.ndarray]) Union[float, numpy.ndarray] [source]¶
- Parameters
x (Union[List[int], int, numpy.ndarray]) -- data point(s) of interest
- Raises
ValueError -- when there exist a value of x not equal to 0 or 1
- Returns
evaluation of cdf at x
- Return type
Union[float, numpy.ndarray]
- median() Union[List[int], int] [source]¶
- Returns
median of Bernoulli distribution
- Return type
Union[List[int], int]
- mode() Union[Tuple[int, int], int] [source]¶
- Returns
mode of Bernoulli distribution
- Return type
Union[Tuple[int, int], int]
- pmf(x: Union[List[int], int, numpy.ndarray]) Union[float, numpy.ndarray] [source]¶
- Parameters
x (Union[List[int], int, numpy.ndarray]) -- random variable(s)
- Raises
ValueError -- when there exist a value of x that is not 0 or 10
- Returns
evaluation of pmf at x
- Return type
Union[float, numpy.ndarray]
- static pmf_s(p: float, x: Union[List[int], int, numpy.ndarray]) Union[float, numpy.ndarray] [source]¶
- Parameters
p (float) -- event of success, either 0 or 1
x (Union[List[int], int, numpy.ndarray]) -- random variable(s)
- Raises
ValueError -- when parameter p does not belong to the domain [0,1]
ValueError -- when there exist a value in a random variable that is not 0 or 1
- Returns
evaluation of pmf at x
- Return type
Union[float, numpy.ndarray]
- class source.discrete.Finite.Binomial(n: int, p: float)[source]¶
Bases:
source.discrete.Finite.Finite
This class contains functions for finding the probability mass function and cumulative distribution function for binomial distirbution 3 4 5.
\[\text{Binomial}(x;n,p) = \binom{n}{x} p^k (1-p)^{n-x}\]- Parameters
n (int) -- number of trials
p (float) -- success probability for each trial. Where 0 <= p <= 1.
x (int) -- number of successes
References
- 3
NIST/SEMATECH e-Handbook of Statistical Methods (2012). Binomial Distribution. Retrieved at http://www.itl.nist.gov/div898/handbook/, December 26, 2000.
- 4
Wikipedia contributors. (2020, December 19). Binomial distribution. https://en.wikipedia.org/w/index.php?title=Binomial_distribution&oldid=995095096
- 5
Weisstein, Eric W. "Binomial Distribution." From MathWorld--A Wolfram Web Resource. https://mathworld.wolfram.com/BinomialDistribution.html
- cdf(x: Union[int, List[int], numpy.ndarray]) Union[int, numpy.ndarray] [source]¶
- Parameters
x (Union[int, List[int], np.ndarray]) -- random variable or list of random variables
- Returns
evaluation of cdf at x
- Return type
Union[int, numpy.ndarray]
- keys() Dict[str, Union[float, int, Tuple[int, int]]] [source]¶
- Returns
Dictionary of Binomial distirbution moments. This includes standard deviation.
- median() Tuple[int, int] [source]¶
- Returns
the median of Binomial Distribution. Either one defined in the tuple of result.
- mode() Tuple[int, int] [source]¶
- Returns
the mode of Binomial Distribution. Either one defined in the tuple of result.
- class source.discrete.Finite.Finite[source]¶
Bases:
discrete._base.Base
- Description:
Base class for probability tags.
- class source.discrete.Finite.Geometric(p: float)[source]¶
Bases:
source.discrete.Finite.Finite
This class contains functions for finding the probability mass function and cumulative distribution function for geometric distribution. We consider two definitions of the geometric distribution: one concerns itself to the number of X of Bernoulli trials needed to get one success, supported on the set {1,2,3,...}. The second one concerns with Y=X-1 of failures before the first success, supported on the set {0,1,2,3,...} 6 7.
\[\text{Geometric}_1(x;p) = (1-p)^{x-1}p\]\[\text{Geometric}_2(x;p) = (1-p)^{x}p\]- Parameters
p (float) -- success probability for each trial. Where 0 <= p <= 1.
x (int) -- number of successes
References
- 6
Weisstein, Eric W. "Geometric Distribution." From MathWorld--A Wolfram Web Resource. https://mathworld.wolfram.com/GeometricDistribution.html
- 7
Wikipedia contributors. (2020, December 27). Geometric distribution. https://en.wikipedia.org/w/index.php?title=Geometric_distribution&oldid=996517676
Note: Geometric distribution can be configured based through _type parameter in pmf, cdf and moments of the distribution, including the std. The default type is _type='first', or \(\text{Geometric_1}(x;p)\).
- cdf(x: Union[List[int], int], _type: str = 'first') Union[numpy.ndarray, float] [source]¶
- Parameters
x (Union[List[int], int, numpy.ndarray]) -- random variable(s)
_type (str, optional) -- optional specifier for modifying the type of Geometric distribution. Defaults to 'first'.
- Raises
TypeError -- when random variable(s) are not of type int
ValueError -- when a _type parameter is not 'first' or second
- Returns
evaluation of cdf at x
- Return type
Union[numpy.ndarray, float]
- keys() Dict[str, Union[float, int]] [source]¶
- Returns
Dictionary of Geometric distirbution moments. This includes standard deviation.
- mean(_type='first') float [source]¶
- Parameters
_type (str, optional) -- modifies the type of Geometric distribution. Defaults to 'first'.
- Raises
ValueError -- when _type is not 'first' or 'second'
- Returns
mean of Geometric distribution
- Return type
float
- median(_type='first') int [source]¶
- Parameters
_type (str, optional) -- modifies the type of Geometric distribution. Defaults to 'first'.
- Raises
ValueError -- when _type is not 'first' or 'second'
- Returns
median of Geometric distribution
- Return type
int
- mode(_type: str = 'first') int [source]¶
- Parameters
_type (str, optional) -- modifies the type of Geometric distribution. Defaults to 'first'.
- Raises
ValueError -- when _type is not 'first' or 'second'
- Returns
mode of Geometric distribution
- Return type
int
- pmf(x: Union[List[int], int, numpy.ndarray], _type: str = 'first') Union[numpy.ndarray, float] [source]¶
- Parameters
x (Union[List[int], int, numpy.ndarray]) -- random variable(s)
_type (str, optional) -- optional specifier for modifying the type of Geometric distribution. Defaults to 'first'.
- Raises
TypeError -- when random variable(s) are not of type int
ValueError -- when a _type parameter is not 'first' or second
- Returns
evaluation of pmf at x
- Return type
Union[numpy.ndarray, float]
- class source.discrete.Finite.Hypergeometric(N: int, K: int, n: int)[source]¶
Bases:
source.discrete.Finite.Finite
This class contains methods concerning pmf and cdf evaluation of the hypergeometric distribution. Describes the probability if k successes (random draws for which the objsect drawn has specified deature) in n draws, without replacement, from a finite population size N that contains exactly K objects with that feature, wherein each draw is either a success or a failure 8 9 10.
\[\text{Hypergeometric}(x;N,K,n) = {{{K \choose x}{{N-K} \choose {n-x}}} \over {N \choose n}}\]- Parameters
N (int) -- population size \(N > 0\)
K (int) -- number of success states in the population \(K > 0\)
n (int) -- number of draws \(n > 0\)
k (int) -- number of observed successes \(x > 0\)
References
- 8
Weisstein, Eric W. "Hypergeometric Distribution." From MathWorld--A Wolfram Web Resource. https://mathworld.wolfram.com/HypergeometricDistribution.html
- 9
Wikipedia contributors. (2020, December 22). Hypergeometric distribution. https://en.wikipedia.org/w/index.php?title=Hypergeometric_distribution&oldid=995715954
- 10
Wolfram Research (2007). HypergeometricDistribution. https://reference.wolfram.com/language/ref/HypergeometricDistribution.html.
- cdf()[source]¶
- Parameters
x (List[int]) -- random variable or list of random variables
- Returns
either cumulative density evaluation for some point or scatter plot of Hypergeometric distribution.
- median() str [source]¶
- Returns
the median of Hypergeometric Distribution. Currently unsupported or undefined.
- pmf(x: Union[List, numpy.ndarray, float]) Union[numpy.ndarray, float] [source]¶
- Returns
evaluation of pmf
- Return type
float
- class source.discrete.Finite.Uniform(a: int, b: int)[source]¶
Bases:
source.discrete.Finite.Finite
This contains methods for finding the probability mass function and cumulative distribution function of Uniform distribution. Incudes scatter plot 11.
\[\text{Uniform} (a,b) = {\begin{cases}{\frac {1}{b-a}}&\mathrm {for} \ a\leq x\leq b,\ \[8pt]0&\mathrm {for} \ x<a\ \mathrm {or} \ x>b\end{cases}}\]- Parameters
data (int) -- sample size
- Reference:
- 11
NIST/SEMATECH e-Handbook of Statistical Methods (2012). Uniform Distribution. Retrieved from http://www.itl.nist.gov/div898/handbook/, December 26, 2020.
- cdf(x: Union[List[int], numpy.ndarray, int]) Union[float, numpy.ndarray] [source]¶
- Parameters
x (Union[List[int], np.ndarray, int]) -- data point(s)
- Returns
evaluation of cdf at x
- Return type
Union[float, np.ndarray]
- pmf(x: Union[List[int], numpy.ndarray, int]) Union[float, numpy.ndarray] [source]¶
- Parameters
x (Union[List[int], np.ndarray, int]) -- random variable(s)
- Returns
evaluation of pmf at x
- Return type
Union[float, np.ndarray]
source.discrete.Infinite module¶
- class source.discrete.Infinite.Borel(mu: float)[source]¶
Bases:
source.discrete.Infinite.Infinite
This class contains methods concerning the Borel Distribution 12.
\[\text{Borel}(x;\mu) = \frac{e^{-\mu x}(\mu x)^{x-1}}{x!}\]- Parameters
mu (float) -- mu parameter \(\mu \in [0,1]\).
x (int) -- random variables
- Reference:
- 12
Wikipedia Contributors (2021). Borel Distribution. https://en.wikipedia.org/wiki/Borel_distribution
- class source.discrete.Infinite.GaussKuzmin[source]¶
Bases:
source.discrete.Infinite.Infinite
This class contains methods concerning the Gauss-Kuzmin distribution 13 .
\[\text{GaussKuzmin}(x) = -\log_2 \Big[ 1- \frac{1}{(k+1)^2}\Big]\]- Parameters
x (int) -- random variables \(x \in (0,\inf]\)
- Reference:
- 13
Wikipedia Contributors (2021). Gauss-Kuzmin distribution. https://en.wikipedia.org/wiki/Gauss%E2%80%93Kuzmin_distribution.
- entropy() float [source]¶
Reference: N. Blachman (1984). The Continued fraction as an information source (Corresp.). IEEE Transactions on Information Theor (Volume: 30, Issue: 4). DOI: 10.1109/TIT.1984.1056924.
- class source.discrete.Infinite.Infinite[source]¶
Bases:
discrete._base.Base
- Description:
Base class for probability tags.
- class source.discrete.Infinite.Logarithmic(p: float)[source]¶
Bases:
source.discrete.Infinite.Infinite
This class contains methods concerning Logarithmic distirbution 14.
\[\text{Logarithmic}(x;p) = \frac{-1}{\ln(1-p)} \ \frac{p^k}{k}\]- Parameters
p (float) -- p parameter
x (int) -- random variable
- Reference:
- 14
Wikipedia Contributors (2020). Logarithmic distirbution. https://en.wikipedia.org/wiki/Logarithmic_distribution.
- class source.discrete.Infinite.Poisson(λ: float)[source]¶
Bases:
source.discrete.Infinite.Infinite
This class contains methods for evaluating some properties of the poisson distribution. As lambda increases to sufficiently large values, the normal distribution (λ, λ) may be used to approximate the Poisson distribution 15 16 17.
Use the Poisson distribution to describe the number of times an event occurs in a finite observation space.
\[\text{Poisson}(x;\lambda) = \frac{\lambda ^{x} e^{- \lambda}}{x!}\]- Parameters
λ (float) -- expected rate if occurrences.
x (int) -- number of occurrences.
References
- 15
Minitab (2019). Poisson Distribution. https://bityl.co/4uYc
- 16
Weisstein, Eric W. "Poisson Distribution." From MathWorld--A Wolfram Web Resource. https://mathworld.wolfram.com/PoissonDistribution.html.
- 17
Wikipedia contributors. (2020, December 16). Poisson distribution. https://en.wikipedia.org/w/index.php?title=Poisson_distribution&oldid=994605766
- cdf(x: Union[List[int], int, numpy.ndarray]) Union[float, numpy.ndarray] [source]¶
- Parameters
x (Union[List[int], int, np.ndarray]) -- data point(s) of interest
- Raises
TypeError -- when types are not of type integer
ValueError -- when x is les than 0
- Returns
evaluation of cdf at x
- Return type
Union[float, np.ndarray]
- pmf(x: Union[List[int], int, numpy.ndarray]) Union[float, numpy.ndarray] [source]¶
- Parameters
x (Union[List[int], int, np.ndarray]) -- random variable(s)
- Raises
TypeError -- when types not of type integer
ValueError -- when x is less than 0
- Returns
evaluation of pmf at x
- Return type
Union[float, np.ndarray]
- class source.discrete.Infinite.YulleSimon(shape: float)[source]¶
Bases:
source.discrete.Infinite.Infinite
This class contains methods concerning the Yulle-Simon Distribution 18.
\[\text{YulleSimon}(x;\rho) = \rho\text{B}(x,\rho+1)\]- Parameters
shape (float) -- shape parameter \(\rho > 0\)
x (float) -- random variables
- Reference:
- 18
Wikipedia Contributors (2021). Yulle-Simon distribution. https://en.wikipedia.org/wiki/Yule%E2%80%93Simon_distribution.
- std() Union[float, str] [source]¶
Default implementation of the standard deviation. Returns NotImplemented.
- class source.discrete.Infinite.Zeta(s: float)[source]¶
Bases:
source.discrete.Infinite.Infinite
This class contains methods concerning the Zeta Distribution 19 20.
\[\text{Zeta}(x;s) =\frac{\frac{1}{x^s}}{\zeta(s)}\]- Parameters
s (-) -- main parameter
x (-) -- support parameter
References
- 19
Wikipedia contributors. (2020, November 6). Zeta distribution. In Wikipedia, The Free Encyclopedia. Retrieved 10:24, December 26, 2020, from https://en.wikipedia.org/w/index.php?title=Zeta_distribution&oldid=987351423
- 20
The Zeta Distribution. (2021, February 3). https://stats.libretexts.org/@go/page/10473
- cdf(x: List[int]) Union[int, float, List[int]] [source]¶
- Parameters
x (List[int]) -- random variables.
- Returns
evaluation of cdf at x. Currently NotImplemented
- Return type
Union[int, float, List[int]]
- pmf(x: Union[List[int], numpy.ndarray, int]) Union[float, numpy.ndarray] [source]¶
- Parameters
x (Union[List[int], np.ndarray, int]) -- random variable(s)
- Raises
TypeError -- when types are not of type integer
- Returns
evaluation of pmf at x
- Return type
Union[float, np.ndarray]
- std() Union[str, float] [source]¶
- Returns
the standard deviation of Zeta Distribution. Returns undefined if variance is undefined.