A Typescript model of the Normal (or Gaussian) distribution.
import { Gaussian } from "@searchlight.ai/gaussian-typescript";
const distribution = new Gaussian(mean, variance);
const cdf = distribution.cdf(25);
cdf.add(new Gaussian(1,2))mean: the mean (μ) of the distributionvariance: the variance (σ^2) of the distributionstandardDeviation: the standard deviation (σ) of the distribution
pdf(x): the probability density function, which describes the probability of a random variable taking on the value xcdf(x): the cumulative distribution function, which describes the probability of a random variable falling in the interval (−∞, x]ppf(x): the percent point function, the inverse of cdf
mul(d): updates the product distribution of this and the given distribution;div(d): updates the quotient distribution of this and the given distribution;mul_constant(d): updatesscale(d); equivalent to callingmul(d: number)div_constant(d): updatesscale(1/d); equivalent to callingdiv(d: number)add(d): updates the result of adding this and the given distribution's means and variancessub(d): updates the result of subtracting this and the given distribution's means and variancesscale(c): updates the result of scaling this distribution by the given constant
The original package while great creates a new Gaussian object on every combination function. One slight optimization in this library is that rather than creating a new Gaussian object on every call, we will update our Gaussian's objects instance variables.