1 /++ 2 This package publicly imports `mir.stat.*` modules. 3 4 $(BOOKTABLE , 5 $(TR 6 $(TH Modules) 7 $(TH Description) 8 ) 9 $(TR $(TDNW $(MREF mir,stat,constant)) $(TD Constants used in other statistical modules )) 10 $(TR $(TDNW $(MREF mir,stat,descriptive)) $(TD Descriptive Statistics )) 11 $(TR $(TDNW $(MREF mir,stat,distribution)) $(TD Statistical Distributions )) 12 $(TR $(TDNW $(MREF mir,stat,inference)) $(TD Probability Density/Mass Functions )) 13 $(TR $(TDNW $(MREF mir,stat,transform)) $(TD Algorithms for statistical inference )) 14 ) 15 16 ## Example 17 ------ 18 import mir.algorithm.iteration: all; 19 import mir.math.common: approxEqual, pow; 20 import mir.stat; 21 import mir.test: shouldApprox; 22 23 // mir.stat.descriptive 24 auto x = [1.0, 2, 3, 4]; 25 x.mean.shouldApprox == 2.5; 26 x.kurtosis.shouldApprox == -1.2; 27 28 // mir.stat.distribution 29 4.binomialPMF(6, 2.0 / 3).shouldApprox == (15.0 * pow(2.0 / 3, 4) * pow(1.0 / 3, 2)); 30 31 // mir.stat.transform 32 assert(x.zscore.all!approxEqual([-1.161895, -0.387298, 0.387298, 1.161895])); 33 34 // mir.stat.inference 35 auto y = [0.0, 1.0, 1.5, 2.0, 3.5, 4.25, 36 2.0, 7.5, 5.0, 1.0, 1.5, 0.0]; 37 double p; 38 y.dAgostinoPearsonTest(p).shouldApprox == 4.151936053369771; 39 ------ 40 41 License: $(HTTP www.apache.org/licenses/LICENSE-2.0, Apache-2.0) 42 43 Authors: John Michael Hall, Ilya Yaroshenko 44 45 Copyright: 2022 Mir Stat Authors. 46 47 Macros: 48 SUBREF = $(REF_ALTTEXT $(TT $2), $2, mir, stat, $1)$(NBSP) 49 MATHREF = $(GREF_ALTTEXT mir-algorithm, $(TT $2), $2, mir, math, $1)$(NBSP) 50 NDSLICEREF = $(GREF_ALTTEXT mir-algorithm, $(TT $2), $2, mir, ndslice, $1)$(NBSP) 51 T2=$(TR $(TDNW $(LREF $1)) $(TD $+)) 52 T4=$(TR $(TDNW $(LREF $1)) $(TD $2) $(TD $3) $(TD $4)) 53 54 +/ 55 56 module mir.stat; 57 58 /// 59 public import mir.stat.constant; 60 /// 61 public import mir.stat.descriptive; 62 /// 63 public import mir.stat.distribution; 64 /// 65 public import mir.stat.inference; 66 /// 67 public import mir.stat.transform; 68 69 // Match comment above to ensure no errors 70 version(mir_stat_test) 71 @safe pure nothrow 72 unittest 73 { 74 import mir.algorithm.iteration: all; 75 import mir.math.common: approxEqual, pow; 76 import mir.stat; 77 import mir.test: shouldApprox; 78 79 // mir.stat.descriptive 80 auto x = [1.0, 2, 3, 4]; 81 x.mean.shouldApprox == 2.5; 82 x.kurtosis.shouldApprox == -1.2; 83 84 // mir.stat.distribution 85 4.binomialPMF(6, 2.0 / 3).shouldApprox == (15.0 * pow(2.0 / 3, 4) * pow(1.0 / 3, 2)); 86 87 // mir.stat.transform 88 assert(x.zscore.all!approxEqual([-1.161895, -0.387298, 0.387298, 1.161895])); 89 90 // mir.stat.inference 91 auto y = [0.0, 1.0, 1.5, 2.0, 3.5, 4.25, 92 2.0, 7.5, 5.0, 1.0, 1.5, 0.0]; 93 double p; 94 y.dAgostinoPearsonTest(p).shouldApprox == 4.151936053369771; 95 }