1 /++ 2 This module publicly imports all classes. 3 4 Import: 5 -------- 6 import atmosphere; 7 -------- 8 9 Class_hierarchy: 10 - [MixtureOptimizer](atmosphere/mixture/MixtureOptimizer.html) 11 - [ExpectationMaximization](atmosphere/mixture/ExpectationMaximization.html) 12 - [LikelihoodAscentEM](atmosphere/mixture/LikelihoodAscentEM.html) : [LikelihoodAscent](atmosphere/mixture/LikelihoodAscent.html) 13 - [GradientDescent](atmosphere/mixture/GradientDescent.html) 14 - [GradientDescentPartial](atmosphere/mixture/GradientDescentPartial.html) 15 - [LikelihoodAscentGradient](atmosphere/mixture/LikelihoodAscentGradient.html) : [LikelihoodAscent](atmosphere/mixture/LikelihoodAscent.html) 16 - [CoordinateDescent](atmosphere/mixture/CoordinateDescent.html) 17 - [CoordinateDescentPartial](atmosphere/mixture/CoordinateDescentPartial.html) 18 - [LikelihoodAscentCoordinate](atmosphere/mixture/LikelihoodAscentCoordinate.html) : [LikelihoodAscent](atmosphere/mixture/LikelihoodAscent.html) 19 - [NvmmLikelihoodAscentEM](atmosphere/parametrized/nvmm/NvmmLikelihoodAscentEM.html) : [LikelihoodAscent](atmosphere/mixture/LikelihoodAscent.html) 20 - [NvmmLikelihoodAscentEMEM](atmosphere/parametrized/nvmm/NvmmLikelihoodAscentEMEM.html) 21 - [NvmmLikelihoodAscentEMGradient](atmosphere/parametrized/nvmm/NvmmLikelihoodAscentEMGradient.html) 22 - [NvmmLikelihoodAscentEMCoordinate](atmosphere/parametrized/nvmm/NvmmLikelihoodAscentEMCoordinate.html) 23 24 See_Also: [Atmosphere GM Test](https://github.com/9il/atmosphere_gm_test) 25 26 +/ 27 28 /+ 29 30 Table of separating mixtures algorithms: 31 $(TABLE 32 $(TR $(TH Class) $(TH BLAS Level 2 % of all computations) $(TH Non-BLAS parallel) $(TH Speed (one thread & big data) ) $(TH Global maximum for convex function) $(TH Parameterized)) 33 $(TR $(TD [GradientDescent](atmosphere/mixture/GradientDescent.html), number of mixture components > ~16) $(TD ~95-99%) $(TD No) $(TD normal ) $(TD Yes) $(TD No) ) 34 $(TR $(TD [GradientDescent](atmosphere/mixture/GradientDescent.html), number of mixture components < ~16) $(TD ~95-99%) $(TD No) $(TD fast ) $(TD Yes) $(TD No) ) 35 $(TR $(TD [CoordinateDescent](atmosphere/mixture/CoordinateDescent.html)) $(TD ~10-50%) $(TD No) $(TD fast ) $(TD Yes) $(TD No) ) 36 $(TR $(TD [CoordinateDescentPartial](atmosphere/mixture/LikelihoodAscentCoordinate.html)) $(TD ~10-50%) $(TD No) $(TD fast, always faster then CoordinateDescent ) $(TD Yes) $(TD No) ) 37 $(TR $(TD [NvmmLikelihoodAscentEMEM](atmosphere/parametrized/nvmm/NvmmLikelihoodAscentEMEM.html)) $(TD ~10%) $(TD Yes) $(TD slow ) $(TD No) $(TD Yes) ) 38 $(TR $(TD [NvmmLikelihoodAscentEMGradient](atmosphere/parametrized/nvmm/NvmmLikelihoodAscentEMGradient.html)) $(TD ~10%) $(TD Yes) $(TD slow ) $(TD No) $(TD Yes) ) 39 $(TR $(TD [NvmmLikelihoodAscentEMCoordinate](atmosphere/parametrized/nvmm/NvmmLikelihoodAscentEMCoordinate.html)) $(TD ~5%) $(TD Partial) $(TD slow ) $(TD No) $(TD Yes) ) ) 40 +/ 41 /** 42 Authors: [Ilya Yaroshenko](http://9il.github.io) 43 44 Copyright: © 2014-2015 [Ilya Yaroshenko](http://9il.github.io) 45 46 License: MIT 47 */ 48 module atmosphere; 49 50 /// 51 unittest 52 { 53 import core.time; 54 import std.random; 55 import std.range; 56 import std.algorithm; 57 import atmosphere; 58 59 alias F = double; 60 61 final class ProperGeneralizedInverseGaussianQuantile(T) : NumericQuantile!T { 62 this(T lambda, T eta, T omega) { 63 auto cdf = new ProperGeneralizedInverseGaussianCDF!T(lambda, eta, omega); 64 super(cdf, -1000, 1000); 65 } 66 } 67 68 nothrow @nogc bool findRootTolerance(F a, F b) { return b/a < 1.001;} 69 70 immutable quantileL = 0.01; 71 immutable quantileR = 0.99; 72 immutable gridSize = 100; 73 immutable dur = TickDuration.from!"msecs"(100); 74 immutable lambda = 2; 75 immutable eta = 1; 76 immutable omega = 2.3; 77 immutable beta = 0.5; 78 immutable sampleSize = 1000; 79 // GIG quantile function 80 auto qf = new ProperGeneralizedInverseGaussianQuantile!F(lambda, eta, omega); 81 // GHyp random number generator 82 auto rng = new ProperGeneralizedHyperbolicRNG!F(rndGen, lambda, eta, omega, beta); 83 // left GIG bound 84 immutable begin = qf(quantileL); 85 // right GIG bound 86 immutable end = qf(quantileR); 87 // grid's step 88 immutable step = (end-begin)/gridSize; 89 // GIG grid 90 immutable grid = iota(begin, end+step/2, step).array; 91 // Normal PDFs for common algorithms 92 auto pdfs = grid.map!(u => NvmmLikelihoodAscentEM!F.CorePDF(beta, u)).array; 93 // GHyp sample 94 immutable sample = cast(immutable) rng.take(sampleSize).array; 95 // Mixture optimizer 96 auto optimizer = new LikelihoodAscentEM!F(pdfs.length, sample.length); 97 // Puts sample 98 optimizer.put(pdfs, sample); 99 // Tuple of time and iterations count 100 immutable result = optimizer.evaluate(dur, &findRootTolerance); 101 } 102 103 public import atmosphere.cdf; 104 public import atmosphere.derivative; 105 public import atmosphere.finitemixture; 106 public import atmosphere.mixture; 107 public import atmosphere.moment; 108 public import atmosphere.params; 109 public import atmosphere.pdf; 110 public import atmosphere.quantile; 111 public import atmosphere.random; 112 113 public import atmosphere.estimate; 114 public import atmosphere.likelihood;