The OpenD Programming Language

1 /++
2 This package publicly imports `mir.stat.distribution.*` modules.
3 
4 ------
5 import mir.math.common: pow;
6 import mir.stat.distribution;
7 import mir.test: shouldApprox;
8 
9 4.binomialPMF(6, 2.0 / 3).shouldApprox == (15.0 * pow(2.0 / 3, 4) * pow(1.0 / 3, 2));
10 ------
11 
12 Each individual distribution module contains - where feasible - functions for:
13 - Probability density/mass functions (e.g. `mir.stat.distribution.*PDF`/`mir.stat.distribution.*PMF`)
14 - Cumulative distriution functions (e.g. `mir.stat.distribution.*CDF`)
15 - Complementary cumulative distribution functions (e.g. `mir.stat.distribution.*CCDF`)
16 - Inverse cumulative distribution functions (e.g. `mir.stat.distribution.*InvCDF`)
17 - Log probaiity density/mass functions (e.g. `mir.stat.distribution.*LPDF`/`mir.stat.distribution.*LPMF`)
18 
19 In addition, convenience modules are provided ($(MREF mir,stat,distribution,pdf), 
20 $(MREF mir,stat,distribution,cdf), $(MREF mir,stat,distribution,invcdf)) that publicly
21 import only the respective functions from each individual distribution module 
22 (note: the pdf module also contains pmfs). 
23 
24 Some (discrete) distributions include multiple algorithms for calculating the
25 included functions. The default is a direct calculation with others being
26 approximations. As a convention, these modules leave it to the user to determine
27 when to switch between the different approximations. Care should be taken if
28 more extreme parameters are used as it can have an impact on speed.
29 
30 $(BOOKTABLE ,
31     $(TR
32         $(TH Modules)
33         $(TH Description)
34     )
35     $(LEADINGROW Convenience Modules (with public imports))
36     $(TR $(TDNW $(MREF mir,stat,distribution)) $(TD Statistical Distributions ))
37     $(TR $(TDNW $(MREF mir,stat,distribution,pdf)) $(TD Probability Density/Mass Functions ))
38     $(TR $(TDNW $(MREF mir,stat,distribution,cdf)) $(TD Cumulative Distribution Functions ))
39     $(TR $(TDNW $(MREF mir,stat,distribution,invcdf)) $(TD Inverse Cumulative Distribution Functions ))
40     $(LEADINGROW Univariate Discrete Distributions)
41     $(TR $(TDNW $(MREF mir,stat,distribution,bernoulli)) $(TD Bernoulli Distribution ))
42     $(TR $(TDNW $(MREF mir,stat,distribution,binomial)) $(TD Binomial Distribution ))
43     $(TR $(TDNW $(MREF mir,stat,distribution,geometric)) $(TD Geometric Distribution ))
44     $(TR $(TDNW $(MREF mir,stat,distribution,hypergeometric)) $(TD Hypergeometric Distribution ))
45     $(TR $(TDNW $(MREF mir,stat,distribution,negative_binomial)) $(TD Negative Binomial Distribution ))
46     $(TR $(TDNW $(MREF mir,stat,distribution,poisson)) $(TD Poisson Distribution ))
47     $(TR $(TDNW $(MREF mir,stat,distribution,uniform_discrete)) $(TD Discrete Uniform Distribution ))
48     $(LEADINGROW Univariate Continuous Distributions)
49     $(TR $(TDNW $(MREF mir,stat,distribution,beta)) $(TD Beta Distribution ))
50     $(TR $(TDNW $(MREF mir,stat,distribution,beta_proportion)) $(TD Beta Proportion Distribution ))
51     $(TR $(TDNW $(MREF mir,stat,distribution,cauchy)) $(TD Cauchy Distribution ))
52     $(TR $(TDNW $(MREF mir,stat,distribution,chi2)) $(TD Chi-squared Distribution ))
53     $(TR $(TDNW $(MREF mir,stat,distribution,cornish_fisher)) $(TD Cornish-Fisher Expansion ))
54     $(TR $(TDNW $(MREF mir,stat,distribution,exponential)) $(TD Exponential Distribution ))
55     $(TR $(TDNW $(MREF mir,stat,distribution,f)) $(TD F Distribution ))
56     $(TR $(TDNW $(MREF mir,stat,distribution,gamma)) $(TD Gamma Distribution ))
57     $(TR $(TDNW $(MREF mir,stat,distribution,generalized_pareto)) $(TD Generalized Pareto Distribution ))
58     $(TR $(TDNW $(MREF mir,stat,distribution,gev)) $(TD Generalized Extreme Value (GEV) Distribution ))
59     $(TR $(TDNW $(MREF mir,stat,distribution,laplace)) $(TD Laplace Distribution ))
60     $(TR $(TDNW $(MREF mir,stat,distribution,log_normal)) $(TD Log-normal Distribution ))
61     $(TR $(TDNW $(MREF mir,stat,distribution,logistic)) $(TD Logistic Distribution ))
62     $(TR $(TDNW $(MREF mir,stat,distribution,normal)) $(TD Normal Distribution ))
63     $(TR $(TDNW $(MREF mir,stat,distribution,pareto)) $(TD Pareto Distribution ))
64     $(TR $(TDNW $(MREF mir,stat,distribution,rayleigh)) $(TD Rayleigh Distribution ))
65     $(TR $(TDNW $(MREF mir,stat,distribution,students_t)) $(TD Student's t Distribution ))
66     $(TR $(TDNW $(MREF mir,stat,distribution,uniform)) $(TD Continuous Uniform Distribution ))
67     $(TR $(TDNW $(MREF mir,stat,distribution,weibull)) $(TD Weibull Distribution ))
68     $(LEADINGROW Multivariate Distributions)
69     $(TR $(TDNW $(MREF mir,stat,distribution,categorical)) $(TD Categorical Distribution ))
70 )
71 
72 License: $(HTTP www.apache.org/licenses/LICENSE-2.0, Apache-2.0)
73 
74 Authors: John Michael Hall, Ilya Yaroshenko
75 
76 Copyright: 2022-3 Mir Stat Authors.
77 
78 +/
79 
80 module mir.stat.distribution;
81 
82 ///
83 public import mir.stat.distribution.bernoulli;
84 ///
85 public import mir.stat.distribution.beta;
86 ///
87 public import mir.stat.distribution.beta_proportion;
88 ///
89 public import mir.stat.distribution.binomial;
90 ///
91 public import mir.stat.distribution.cauchy;
92 ///
93 public import mir.stat.distribution.chi2;
94 ///
95 public import mir.stat.distribution.cornish_fisher;
96 ///
97 public import mir.stat.distribution.exponential;
98 ///
99 public import mir.stat.distribution.f;
100 ///
101 public import mir.stat.distribution.gamma;
102 ///
103 public import mir.stat.distribution.generalized_pareto;
104 ///
105 public import mir.stat.distribution.geometric;
106 ///
107 public import mir.stat.distribution.gev;
108 ///
109 public import mir.stat.distribution.hypergeometric;
110 ///
111 public import mir.stat.distribution.laplace;
112 ///
113 public import mir.stat.distribution.log_normal;
114 ///
115 public import mir.stat.distribution.logistic;
116 ///
117 public import mir.stat.distribution.negative_binomial;
118 ///
119 public import mir.stat.distribution.normal;
120 ///
121 public import mir.stat.distribution.pareto;
122 ///
123 public import mir.stat.distribution.poisson;
124 ///
125 public import mir.stat.distribution.rayleigh;
126 ///
127 public import mir.stat.distribution.students_t;
128 ///
129 public import mir.stat.distribution.uniform;
130 ///
131 public import mir.stat.distribution.uniform_discrete;
132 ///
133 public import mir.stat.distribution.weibull;
134 
135 // Match comment above to ensure no errors
136 version(mir_stat_test)
137 @safe pure nothrow @nogc
138 unittest
139 {
140     import mir.math.common: pow;
141     import mir.stat.distribution;
142     import mir.test: shouldApprox;
143 
144     4.binomialPMF(6, 2.0 / 3).shouldApprox == (15.0 * pow(2.0 / 3, 4) * pow(1.0 / 3, 2));
145 }