# atmosphere

## Modules

cdf
module atmosphere.cdf
derivative
module atmosphere.derivative
estimate
module atmosphere.estimate
finitemixture
module atmosphere.finitemixture
likelihood
module atmosphere.likelihood
math
module atmosphere.math
mixture
module atmosphere.mixture
moment
module atmosphere.moment
params
module atmosphere.params
pdf
module atmosphere.pdf
quantile
module atmosphere.quantile
random
module atmosphere.random
statistic
module atmosphere.statistic
summation
module atmosphere.summation

This module contains basic summation algorithms.

utilities
module atmosphere.utilities

## Examples

```1 import core.time;
2 import std.random;
3 import std.range;
4 import std.algorithm;
5 import atmosphere;
6
7 alias F = double;
8
9 final class ProperGeneralizedInverseGaussianQuantile(T) : NumericQuantile!T {
10 	this(T lambda, T eta, T omega) {
11 		auto cdf = new ProperGeneralizedInverseGaussianCDF!T(lambda, eta, omega);
12 		super(cdf, -1000, 1000);
13 	}
14 }
15
16 nothrow @nogc bool findRootTolerance(F a, F b) { return b/a < 1.001;}
17
18 immutable quantileL  = 0.01;
19 immutable quantileR  = 0.99;
20 immutable gridSize   = 100;
21 immutable dur        = TickDuration.from!"msecs"(100);
22 immutable lambda     = 2;
23 immutable eta        = 1;
24 immutable omega      = 2.3;
25 immutable beta       = 0.5;
26 immutable sampleSize = 1000;
27 // GIG quantile function
28 auto qf              = new ProperGeneralizedInverseGaussianQuantile!F(lambda, eta, omega);
29 // GHyp random number generator
30 auto rng             = new ProperGeneralizedHyperbolicRNG!F(rndGen, lambda, eta, omega, beta);
31 // left GIG bound
32 immutable begin      = qf(quantileL);
33 // right GIG bound
34 immutable end        = qf(quantileR);
35 // grid's step
36 immutable step       = (end-begin)/gridSize;
37 // GIG grid
38 immutable grid       = iota(begin, end+step/2, step).array;
39 // Normal PDFs for common algorithms
40 auto pdfs            = grid.map!(u => NvmmLikelihoodAscentEM!F.CorePDF(beta, u)).array;
41 // GHyp sample
42 immutable sample     = cast(immutable) rng.take(sampleSize).array;
43 // Mixture optimizer
44 auto optimizer       = new LikelihoodAscentEM!F(pdfs.length, sample.length);
45 // Puts sample
46 optimizer.put(pdfs, sample);
47 // Tuple of time and iterations count
48 immutable result     = optimizer.evaluate(dur, &findRootTolerance);```

Ilya Yaroshenko