Distribution objects of fastmath.random: the protocol implementations and the constructors behind the fastmath.random/distribution keys.
The namespace extends the Apache Commons Math RealDistribution and IntegerDistribution and the multivariate normal distribution with the fastmath.protocols distribution protocols, and defines the distributions which have no backend or need a fix: the wrappers of SSJ continuous distributions (ssj-continuous), the distributions implemented here (zero-inflated and zero-adjusted families, generalized families, noncentral families, von-mises, kolmogorov, finite support discrete distributions, multinomial, dirichlet, multi-normal, negative-binomial, logarithmic, beta-binomial and others) and the combinators truncated and mixture. ->distribution builds a distribution object from a map of functions, integrate-pdf and icdf-solver build a cdf and an inverse cdf from a density or a cdf, ccdf computes the upper tail probability.
The functions are the building blocks for fastmath.random, which wraps them with the user-facing constructors (defaults, docstrings, the distribution multimethod) and the protocol proxies (cdf, pdf, icdf ... with the checks of the arguments). Positional arguments of the constructors here are not optional, rng can be nil (a fresh generator is created). Invalid arguments throw ex-info with :type :invalid-input.
Distribution objects of `fastmath.random`: the protocol implementations and the constructors behind the `fastmath.random/distribution` keys. The namespace extends the Apache Commons Math `RealDistribution` and `IntegerDistribution` and the multivariate normal distribution with the `fastmath.protocols` distribution protocols, and defines the distributions which have no backend or need a fix: the wrappers of SSJ continuous distributions (`ssj-continuous`), the distributions implemented here (zero-inflated and zero-adjusted families, generalized families, noncentral families, `von-mises`, `kolmogorov`, finite support discrete distributions, `multinomial`, `dirichlet`, `multi-normal`, `negative-binomial`, `logarithmic`, `beta-binomial` and others) and the combinators `truncated` and `mixture`. `->distribution` builds a distribution object from a map of functions, `integrate-pdf` and `icdf-solver` build a cdf and an inverse cdf from a density or a cdf, `ccdf` computes the upper tail probability. The functions are the building blocks for `fastmath.random`, which wraps them with the user-facing constructors (defaults, docstrings, the `distribution` multimethod) and the protocol proxies (`cdf`, `pdf`, `icdf` ... with the checks of the arguments). Positional arguments of the constructors here are not optional, `rng` can be `nil` (a fresh generator is created). Invalid arguments throw `ex-info` with `:type :invalid-input`.
(->distribution {:keys [pdf lpdf cdf icdf rng dimensions continuous?
integer-support? name parameters mean variance
lower-bound upper-bound sampler seeder fit-spec]
:or {dimensions 1}})Creates a distribution object from the given functions (:pdf, :lpdf, :cdf, :icdf, :sampler, ...).
Parameters (a map):
pdf, lpdf: density (mass) and its logarithm, functions of a double (of a long for discrete distributions on the integers); one of them is enough, the other is derivedcdf: cumulative distribution functionicdf: quantile function; it is also the default sampler (applied to a uniform number from rng)sampler: function without arguments returning a sample, or :long for a quantile based sampler returning longsseeder: function of a seed called by set-seed!, default reseeds rngrng: random generator (nil: a fresh one)dimensions (long, default 1), continuous?, integer-support? (discrete distributions: false for the real valued ones)name, parameters: values of distribution-id and distribution-parametersfit-spec: the value of fit-spec, the fitting specification or the keyword naming one in fastmath.fitdistr.fit-specs (default nil: the distribution can't be fitted)mean, variance: numbers or delays (evaluated on first request)lower-bound, upper-bound: bounds of the supportThe result is a univariate distribution (dimensions is only reported); source-object is the object itself, grandom, brandom and set-seed throw UnsupportedOperationException.
For discrete distributions on the integers (:continuous? false, unless :integer-support? is false) the :pdf, :lpdf and :cdf
functions are called with integer (long) arguments only: pdf and probability return 0.0 and lpdf -Inf for a non-integer
argument, cdf floors its argument and is 0.0 below :lower-bound, NaN is passed through as NaN. Discrete distributions on
arbitrary real numbers set :integer-support? to false and receive the argument unchanged.
Creates a distribution object from the given functions (`:pdf`, `:lpdf`, `:cdf`, `:icdf`, `:sampler`, ...). Parameters (a map): - `pdf`, `lpdf`: density (mass) and its logarithm, functions of a double (of a long for discrete distributions on the integers); one of them is enough, the other is derived - `cdf`: cumulative distribution function - `icdf`: quantile function; it is also the default sampler (applied to a uniform number from `rng`) - `sampler`: function without arguments returning a sample, or `:long` for a quantile based sampler returning longs - `seeder`: function of a seed called by `set-seed!`, default reseeds `rng` - `rng`: random generator (`nil`: a fresh one) - `dimensions` (long, default 1), `continuous?`, `integer-support?` (discrete distributions: `false` for the real valued ones) - `name`, `parameters`: values of `distribution-id` and `distribution-parameters` - `fit-spec`: the value of `fit-spec`, the fitting specification or the keyword naming one in `fastmath.fitdistr.fit-specs` (default `nil`: the distribution can't be fitted) - `mean`, `variance`: numbers or delays (evaluated on first request) - `lower-bound`, `upper-bound`: bounds of the support The result is a univariate distribution (`dimensions` is only reported); `source-object` is the object itself, `grandom`, `brandom` and `set-seed` throw `UnsupportedOperationException`. For discrete distributions on the integers (`:continuous?` false, unless `:integer-support?` is false) the `:pdf`, `:lpdf` and `:cdf` functions are called with integer (`long`) arguments only: `pdf` and `probability` return 0.0 and `lpdf` -Inf for a non-integer argument, `cdf` floors its argument and is 0.0 below `:lower-bound`, NaN is passed through as NaN. Discrete distributions on arbitrary real numbers set `:integer-support?` to false and receive the argument unchanged.
(beta-binomial alpha beta n rng)(beta-binomial alpha beta n rng parameters)(beta-binomial alpha beta n rng parameters fit-spec)Beta-binomial distribution (alpha, beta, n). The optional parameters (default [:alpha :beta :n :rng]) is what
distribution-parameters reports, for the constructors accepting other parameters (bb); the optional fit-spec is the value of fit-spec (nil: the distribution can't be fitted).
Beta-binomial distribution `(alpha, beta, n)`. The optional `parameters` (default `[:alpha :beta :n :rng]`) is what `distribution-parameters` reports, for the constructors accepting other parameters (`bb`); the optional `fit-spec` is the value of `fit-spec` (`nil`: the distribution can't be fitted).
(beta-noncentral alpha beta ncp rng)Noncentral beta distribution with the shapes alpha, beta and the noncentrality ncp.
rng is the random generator (nil: a fresh one). The distribution is a Poisson mixture of central beta distributions with the shape alpha + k (terms are added until their weights sum to 1 - 1e-15, at most 100000), mean and variance are the exact moments of that mixture and icdf is found by root finding. Returns a univariate continuous distribution on [0, 1].
Noncentral beta distribution with the shapes `alpha`, `beta` and the noncentrality `ncp`. `rng` is the random generator (`nil`: a fresh one). The distribution is a Poisson mixture of central beta distributions with the shape `alpha + k` (terms are added until their weights sum to `1 - 1e-15`, at most 100000), `mean` and `variance` are the exact moments of that mixture and `icdf` is found by root finding. Returns a univariate continuous distribution on `[0, 1]`.
(categorical-distribution data probabilities rng)Discrete distribution on an arbitrary finite set of values (keywords, strings, any objects compared by equality).
Parameters:
data: non-empty sequence of values; repeated values are summedprobabilities: non-negative finite weights of the same count, normalised internally; nil: equal weightsrng: random generator (nil: a fresh one)pdf, cdf and probability take a value of the data (a value outside of it gives 0.0), cdf is the cumulative probability in the order in which the distinct values first appear in data, icdf returns the value at which that cumulative probability reaches p and sample a value. The source-object is the integer-discrete distribution over the positions. mean and variance are NaN, the bounds are not supported. Throws ex-info as integer-discrete-distribution.
Discrete distribution on an arbitrary finite set of values (keywords, strings, any objects compared by equality). Parameters: - `data`: non-empty sequence of values; repeated values are summed - `probabilities`: non-negative finite weights of the same count, normalised internally; `nil`: equal weights - `rng`: random generator (`nil`: a fresh one) `pdf`, `cdf` and `probability` take a value of the data (a value outside of it gives `0.0`), `cdf` is the cumulative probability in the order in which the distinct values first appear in `data`, `icdf` returns the value at which that cumulative probability reaches `p` and `sample` a value. The `source-object` is the integer-discrete distribution over the positions. `mean` and `variance` are `NaN`, the bounds are not supported. Throws `ex-info` as `integer-discrete-distribution`.
(ccdf d v)Returns the complementary cumulative probability P(X > v) (the upper tail) of the univariate distribution d.
Parameters:
d: univariate distribution objectv (double): the pointThe value is computed with the most accurate method available:
barF (the folded normal, whose barF is wrong, and the inverse Gaussian, whose barF is just 1 - cdf of an inaccurate SSJ cdf, use 1 - cdf of the distribution instead),normal, t, logistic, laplace, cauchy, exponential, weibull, pareto, log-normal, gamma and chi-squared use closed forms (the regularized incomplete gamma function for gamma and chi-squared), accurate in the far upper tail where 1 - cdf is exactly 0.0,1 - cdf, which loses all digits once the tail probability is below about 1e-16.Returns ##NaN for a NaN argument. No range check is made: outside the support the result is 1.0 (left of it) or 0.0 (right of it) for the closed forms.
Returns the complementary cumulative probability `P(X > v)` (the upper tail) of the univariate distribution `d`. Parameters: - `d`: univariate distribution object - `v` (double): the point The value is computed with the most accurate method available: - distributions backed by an SSJ continuous distribution use its survival function `barF` (the folded normal, whose `barF` is wrong, and the inverse Gaussian, whose `barF` is just `1 - cdf` of an inaccurate SSJ cdf, use `1 - cdf` of the distribution instead), - `normal`, `t`, `logistic`, `laplace`, `cauchy`, `exponential`, `weibull`, `pareto`, `log-normal`, `gamma` and `chi-squared` use closed forms (the regularized incomplete gamma function for `gamma` and `chi-squared`), accurate in the far upper tail where `1 - cdf` is exactly `0.0`, - any other distribution, discrete ones included, uses `1 - cdf`, which loses all digits once the tail probability is below about `1e-16`. Returns `##NaN` for a `NaN` argument. No range check is made: outside the support the result is `1.0` (left of it) or `0.0` (right of it) for the closed forms. See also [[truncated]], [[mixture]].
(continuous-distribution {:keys [data steps kde bandwidth rng] :as all})Nonparametric continuous distribution built from the data by a kernel density estimate.
Parameters (a map):
data: sequence of numberskde: kernel density estimation method, see fastmath.kernel.density/kernel-density+bandwidth: bandwidth of the estimate, nil selects the default onesteps (long): number of subintervals of the numerical integration of the density, from which cdf and icdf are interpolatedinterpolator: interpolation of the integrated density, see integrate-pdfrng: random generator (nil: a fresh one)pdf is the estimate, cdf and icdf come from integrate-pdf on the range of the data extended where the estimate is positive, mean and variance are the sample mean and the sample variance of data, not the moments of the estimate. Returns a univariate continuous distribution.
Nonparametric continuous distribution built from the data by a kernel density estimate. Parameters (a map): - `data`: sequence of numbers - `kde`: kernel density estimation method, see `fastmath.kernel.density/kernel-density+` - `bandwidth`: bandwidth of the estimate, `nil` selects the default one - `steps` (long): number of subintervals of the numerical integration of the density, from which `cdf` and `icdf` are interpolated - `interpolator`: interpolation of the integrated density, see `integrate-pdf` - `rng`: random generator (`nil`: a fresh one) `pdf` is the estimate, `cdf` and `icdf` come from `integrate-pdf` on the range of the data extended where the estimate is positive, `mean` and `variance` are the sample mean and the sample variance of `data`, not the moments of the estimate. Returns a univariate continuous distribution.
(dirichlet alpha gamma rng)Dirichlet distribution on the simplex.
Parameters:
alpha: sequence of positive concentration parameters, an integer n means n parameters equal to 1.0; the dimension is their countgamma: the constructor of the gamma distribution (a function of a map with :shape, :scale and :rng), used for samplingrng: random generator (nil: a fresh one)A sample is a vector of normalised gamma variates (computed in log space when their sum is below 1e-8, so small alpha do not degenerate); zero and one coordinates are moved to the neighbouring double. pdf, lpdf and probability take a sequence with one coordinate per dimension, non-negative and summing to 1 within 1e-8, and use the limits at the boundary (a coordinate zero with alpha < 1 gives +Inf); other points throw ex-info. means and covariance are available, cdf, icdf, mean, variance and bounds are not. Returns a multivariate continuous distribution.
Dirichlet distribution on the simplex. Parameters: - `alpha`: sequence of positive concentration parameters, an integer `n` means `n` parameters equal to `1.0`; the dimension is their count - `gamma`: the constructor of the gamma distribution (a function of a map with `:shape`, `:scale` and `:rng`), used for sampling - `rng`: random generator (`nil`: a fresh one) A sample is a vector of normalised gamma variates (computed in log space when their sum is below `1e-8`, so small `alpha` do not degenerate); zero and one coordinates are moved to the neighbouring double. `pdf`, `lpdf` and `probability` take a sequence with one coordinate per dimension, non-negative and summing to 1 within `1e-8`, and use the limits at the boundary (a coordinate zero with `alpha < 1` gives `+Inf`); other points throw `ex-info`. `means` and `covariance` are available, `cdf`, `icdf`, `mean`, `variance` and bounds are not. Returns a multivariate continuous distribution.
(discrete-binary-search cdf-fn p [mid step])(discrete-binary-search cdf-fn step p [mn mx])Smallest integer k with cdf-fn(k) >= p, found by an exponential and a binary search.
Parameters:
cdf-fn: cdf of an integer-valued distribution, a function of a longp: probability[mid step] (3 arguments): the start, the search begins on [0, mid] and extends the right end with the initial step (at least 1) while cdf-fn is below pstep, [mn mx] (4 arguments): the current step and bracketReturns a long.
Smallest integer `k` with `cdf-fn(k) >= p`, found by an exponential and a binary search. Parameters: - `cdf-fn`: cdf of an integer-valued distribution, a function of a long - `p`: probability - `[mid step]` (3 arguments): the start, the search begins on `[0, mid]` and extends the right end with the initial `step` (at least 1) while `cdf-fn` is below `p` - `step`, `[mn mx]` (4 arguments): the current step and bracket Returns a long.
(ex-gaussian {:keys [mu sigma tau rng normal exponential parameters fit-spec]
:or {parameters [:mu :sigma :tau :rng]
fit-spec fit-specs/ex-gaussian}})Ex-Gaussian distribution, the sum of an independent normal variable (mu, sigma) and an exponential variable with the mean tau.
Parameters (a map): mu, sigma, tau (doubles), rng (nil: a fresh generator), normal and exponential (the constructors of these distributions, functions of a map, passed by fastmath.random), parameters (vector reported by distribution-parameters, default [:mu :sigma :tau :rng]).
The density and the cdf are closed forms with erfc, evaluated in log space in the far tails; icdf is found by root finding. mean is mu + tau, variance is sigma^2 + tau^2. Returns a univariate continuous distribution.
Ex-Gaussian distribution, the sum of an independent normal variable `(mu, sigma)` and an exponential variable with the mean `tau`. Parameters (a map): `mu`, `sigma`, `tau` (doubles), `rng` (`nil`: a fresh generator), `normal` and `exponential` (the constructors of these distributions, functions of a map, passed by `fastmath.random`), `parameters` (vector reported by `distribution-parameters`, default `[:mu :sigma :tau :rng]`). The density and the cdf are closed forms with `erfc`, evaluated in log space in the far tails; `icdf` is found by root finding. `mean` is `mu + tau`, `variance` is `sigma^2 + tau^2`. Returns a univariate continuous distribution.
(f-noncentral df1 df2 ncp rng)Noncentral F distribution with df1 and df2 degrees of freedom and the noncentrality ncp.
rng is the random generator (nil: a fresh one). pdf, cdf and icdf are sums over a Poisson mixture of scaled central F distributions (terms are added until their weights sum to 1 - 1e-15, at most 100000). mean is ##Inf for df2 <= 2 and variance for df2 <= 4. Returns a univariate continuous distribution on [0, Inf).
Noncentral F distribution with `df1` and `df2` degrees of freedom and the noncentrality `ncp`. `rng` is the random generator (`nil`: a fresh one). `pdf`, `cdf` and `icdf` are sums over a Poisson mixture of scaled central F distributions (terms are added until their weights sum to `1 - 1e-15`, at most 100000). `mean` is `##Inf` for `df2 <= 2` and `variance` for `df2 <= 4`. Returns a univariate continuous distribution on `[0, Inf)`.
(fishers-noncentral-hypergeometric {:keys [ns nf n omega rng]})Fisher's noncentral hypergeometric distribution.
The number of items of the first kind in a sample of size n from an urn with ns items of the first and nf of the second kind, when the odds of choosing the first kind are omega times the odds of the second (omega = 1 is the ordinary hypergeometric distribution).
Parameters (a map): ns, nf, n (longs), omega (positive double), rng (nil: a fresh generator). The support is [max(0, n - nf), min(ns, n)]; the probabilities are computed for the whole support at construction, so it should be of moderate size. Returns a univariate discrete distribution.
Fisher's noncentral hypergeometric distribution. The number of items of the first kind in a sample of size `n` from an urn with `ns` items of the first and `nf` of the second kind, when the odds of choosing the first kind are `omega` times the odds of the second (`omega = 1` is the ordinary hypergeometric distribution). Parameters (a map): `ns`, `nf`, `n` (longs), `omega` (positive double), `rng` (`nil`: a fresh generator). The support is `[max(0, n - nf), min(ns, n)]`; the probabilities are computed for the whole support at construction, so it should be of moderate size. Returns a univariate discrete distribution.
(generalized-exponential alpha lambda rng)Generalized (exponentiated) exponential distribution with the shape alpha and the rate lambda, cdf(x) = (1 - exp(-lambda x))^alpha for x >= 0.
rng is the random generator (nil: a fresh one). Returns a univariate continuous distribution on [0, Inf).
Generalized (exponentiated) exponential distribution with the shape `alpha` and the rate `lambda`, `cdf(x) = (1 - exp(-lambda x))^alpha` for `x >= 0`. `rng` is the random generator (`nil`: a fresh one). Returns a univariate continuous distribution on `[0, Inf)`.
(generalized-extreme-value mu sigma xi rng)Generalized extreme value distribution with the location mu, the scale sigma and the shape xi, cdf(x) = exp(-(1 + xi (x - mu) / sigma)^(-1 / xi)); xi = 0 is the Gumbel distribution.
rng is the random generator (nil: a fresh one). mean is ##Inf for xi >= 1 and variance is ##Inf for xi >= 0.5. The support is bounded on the left for xi > 0 and on the right for xi < 0. Returns a univariate continuous distribution.
Generalized extreme value distribution with the location `mu`, the scale `sigma` and the shape `xi`, `cdf(x) = exp(-(1 + xi (x - mu) / sigma)^(-1 / xi))`; `xi = 0` is the Gumbel distribution. `rng` is the random generator (`nil`: a fresh one). `mean` is `##Inf` for `xi >= 1` and `variance` is `##Inf` for `xi >= 0.5`. The support is bounded on the left for `xi > 0` and on the right for `xi < 0`. Returns a univariate continuous distribution.
(generalized-gamma {:keys [mu sigma nu rng gamma log-normal]})Generalized gamma distribution in the gamlss GG parameterisation: u = theta (y / mu)^nu is gamma distributed with the shape theta = 1 / (sigma^2 nu^2).
Parameters (a map): mu (scale), sigma, nu (doubles; nu = 0 is the log-normal distribution with scale = log(mu) and shape = sigma), rng (nil: a fresh generator), gamma and log-normal (the constructors of these distributions, functions of a map). mean and variance are ##Inf when they diverge. Returns a univariate continuous distribution on [0, Inf).
Generalized gamma distribution in the gamlss `GG` parameterisation: `u = theta (y / mu)^nu` is gamma distributed with the shape `theta = 1 / (sigma^2 nu^2)`. Parameters (a map): `mu` (scale), `sigma`, `nu` (doubles; `nu = 0` is the log-normal distribution with `scale = log(mu)` and `shape = sigma`), `rng` (`nil`: a fresh generator), `gamma` and `log-normal` (the constructors of these distributions, functions of a map). `mean` and `variance` are `##Inf` when they diverge. Returns a univariate continuous distribution on `[0, Inf)`.
(generalized-half-logistic alpha lambda rng)Generalized (exponentiated) half-logistic distribution with the shape alpha and the rate lambda: the half-logistic cdf raised to the power alpha.
rng is the random generator (nil: a fresh one). mean and variance are computed by numerical integration on first request. Returns a univariate continuous distribution on [0, Inf).
Generalized (exponentiated) half-logistic distribution with the shape `alpha` and the rate `lambda`: the half-logistic cdf raised to the power `alpha`. `rng` is the random generator (`nil`: a fresh one). `mean` and `variance` are computed by numerical integration on first request. Returns a univariate continuous distribution on `[0, Inf)`.
(generalized-hyperbolic opts)Generalized hyperbolic distribution.
Parameters (a map): mu (location), delta (scale), alpha (tail), beta (skewness, |beta| < alpha), lambda (shape), rng (nil: a fresh generator). A sample is a normal variance-mean mixture with a generalized inverse Gaussian mixing variable. mean and variance are closed forms; cdf and icdf come from the numerical integration of the density on the mean plus or minus 25 standard deviations, so they are approximate. Returns a univariate continuous distribution on the reals.
Generalized hyperbolic distribution. Parameters (a map): `mu` (location), `delta` (scale), `alpha` (tail), `beta` (skewness, `|beta| < alpha`), `lambda` (shape), `rng` (`nil`: a fresh generator). A sample is a normal variance-mean mixture with a generalized inverse Gaussian mixing variable. `mean` and `variance` are closed forms; `cdf` and `icdf` come from the numerical integration of the density on the mean plus or minus 25 standard deviations, so they are approximate. Returns a univariate continuous distribution on the reals.
(generalized-inverse-gaussian {:keys [chi psi lambda rng]})Generalized inverse Gaussian distribution with the density proportional to x^(lambda - 1) exp(-(chi / x + psi x) / 2) on x > 0.
Parameters (a map): chi, psi (positive doubles), lambda (double), rng (nil: a fresh generator). mean and variance are closed forms with the modified Bessel function of the second kind; cdf and icdf are obtained by numerical integration of the density on [0, mean + 25 sd], so they are approximate and cdf is 1.0 beyond that. Returns a univariate continuous distribution.
Generalized inverse Gaussian distribution with the density proportional to `x^(lambda - 1) exp(-(chi / x + psi x) / 2)` on `x > 0`. Parameters (a map): `chi`, `psi` (positive doubles), `lambda` (double), `rng` (`nil`: a fresh generator). `mean` and `variance` are closed forms with the modified Bessel function of the second kind; `cdf` and `icdf` are obtained by numerical integration of the density on `[0, mean + 25 sd]`, so they are approximate and `cdf` is `1.0` beyond that. Returns a univariate continuous distribution.
(generalized-logistic mu sigma alpha rng)Generalized logistic distribution (type I) with the location mu, the scale sigma and the shape alpha, cdf(x) = (1 + exp(-(x - mu) / sigma))^(-alpha).
rng is the random generator (nil: a fresh one). Returns a univariate continuous distribution on the reals.
Generalized logistic distribution (type I) with the location `mu`, the scale `sigma` and the shape `alpha`, `cdf(x) = (1 + exp(-(x - mu) / sigma))^(-alpha)`. `rng` is the random generator (`nil`: a fresh one). Returns a univariate continuous distribution on the reals.
(generalized-normal {:keys [mu alpha beta rng gamma]})Generalized normal (exponential power, Subbotin) distribution with the location mu, the scale alpha and the shape beta; beta = 2 is a normal distribution and beta = 1 the Laplace distribution.
Parameters (a map): mu, alpha, beta (doubles), rng (nil: a fresh generator), gamma (the constructor of the gamma distribution, a function of a map). mean is mu and variance is alpha^2 Gamma(3 / beta) / Gamma(1 / beta). Returns a univariate continuous distribution on the reals.
Generalized normal (exponential power, Subbotin) distribution with the location `mu`, the scale `alpha` and the shape `beta`; `beta = 2` is a normal distribution and `beta = 1` the Laplace distribution. Parameters (a map): `mu`, `alpha`, `beta` (doubles), `rng` (`nil`: a fresh generator), `gamma` (the constructor of the gamma distribution, a function of a map). `mean` is `mu` and `variance` is `alpha^2 Gamma(3 / beta) / Gamma(1 / beta)`. Returns a univariate continuous distribution on the reals.
(generalized-pareto mu sigma xi rng)Generalized Pareto distribution with the location mu, the scale sigma and the shape xi; xi = 0 is the exponential distribution shifted by mu.
rng is the random generator (nil: a fresh one). mean is ##Inf for xi >= 1 and variance is ##Inf for xi >= 0.5. The support is [mu, Inf), and [mu, mu - sigma / xi] for xi < 0. Returns a univariate continuous distribution.
Generalized Pareto distribution with the location `mu`, the scale `sigma` and the shape `xi`; `xi = 0` is the exponential distribution shifted by `mu`. `rng` is the random generator (`nil`: a fresh one). `mean` is `##Inf` for `xi >= 1` and `variance` is `##Inf` for `xi >= 0.5`. The support is `[mu, Inf)`, and `[mu, mu - sigma / xi]` for `xi < 0`. Returns a univariate continuous distribution.
(half-cauchy mu scale rng)Half-Cauchy distribution with the location mu and the scale: the Cauchy density folded at mu, 2 / (pi scale (1 + ((x - mu) / scale)^2)) for x >= mu.
rng is the random generator (nil: a fresh one). mean and variance are NaN. The reported bounds are 0.0 and +Inf whatever mu is. Returns a univariate continuous distribution.
Half-Cauchy distribution with the location `mu` and the `scale`: the Cauchy density folded at `mu`, `2 / (pi scale (1 + ((x - mu) / scale)^2))` for `x >= mu`. `rng` is the random generator (`nil`: a fresh one). `mean` and `variance` are `NaN`. The reported bounds are `0.0` and `+Inf` whatever `mu` is. Returns a univariate continuous distribution.
(half-logistic scale rng)Half-logistic distribution with the scale: the absolute value of a logistic variable, cdf(x) = (1 - exp(-x / scale)) / (1 + exp(-x / scale)) for x >= 0.
rng is the random generator (nil: a fresh one). mean is 2 log(2) scale. Returns a univariate continuous distribution on [0, Inf).
Half-logistic distribution with the `scale`: the absolute value of a logistic variable, `cdf(x) = (1 - exp(-x / scale)) / (1 + exp(-x / scale))` for `x >= 0`. `rng` is the random generator (`nil`: a fresh one). `mean` is `2 log(2) scale`. Returns a univariate continuous distribution on `[0, Inf)`.
(icdf-solver cdf p init step)Solves cdf(x) = p for x, for a cdf which is not bounded on at least one side.
Parameters:
cdf: cdf function of a doublep: target probabilityinit: the starting pointstep: the first step of the search for a bracket of the rootThe bracket is found by moving away from init with steps growing geometrically, then the root is found by a bracketing solver with the absolute accuracy 1e-10. Returns the root as a double, ##Inf or ##-Inf when the bracket leaves the range of doubles.
Solves `cdf(x) = p` for `x`, for a cdf which is not bounded on at least one side. Parameters: - `cdf`: cdf function of a double - `p`: target probability - `init`: the starting point - `step`: the first step of the search for a bracket of the root The bracket is found by moving away from `init` with steps growing geometrically, then the root is found by a bracketing solver with the absolute accuracy `1e-10`. Returns the root as a double, `##Inf` or `##-Inf` when the bracket leaves the range of doubles.
(integer-discrete-distribution data probabilities rng)Discrete distribution on a finite set of integers.
Parameters:
data: non-empty sequence of integers within the long range; repeated values are summedprobabilities: sequence of non-negative finite weights of the same count, normalised internally; nil: equal weightsrng: random generator (nil: a fresh one)icdf is the smallest value with cdf >= p, cdf and the pmf accept any number (a non-integer pdf argument gives 0.0), samples are Longs. Values of data with an absolute value above 2^53 are held as the nearest double (pdf there is 0.0, icdf returns the rounded value). Bounds are the smallest and the largest value. Throws ex-info for invalid data or probabilities (empty data, a different count, negative, NaN or infinite weights, a zero sum). Returns a univariate discrete distribution.
Discrete distribution on a finite set of integers. Parameters: - `data`: non-empty sequence of integers within the long range; repeated values are summed - `probabilities`: sequence of non-negative finite weights of the same count, normalised internally; `nil`: equal weights - `rng`: random generator (`nil`: a fresh one) `icdf` is the smallest value with `cdf >= p`, `cdf` and the pmf accept any number (a non-integer `pdf` argument gives `0.0`), samples are `Long`s. Values of `data` with an absolute value above `2^53` are held as the nearest double (`pdf` there is `0.0`, `icdf` returns the rounded value). Bounds are the smallest and the largest value. Throws `ex-info` for invalid `data` or `probabilities` (empty data, a different count, negative, `NaN` or infinite weights, a zero sum). Returns a univariate discrete distribution.
(integrate-pdf pdf-func
{:keys [mn mx steps interpolator]
:or {mn 0.0 mx 1.0 steps 1000 interpolator :monotone}
:as options})(integrate-pdf pdf-func mn mx steps)Integrates the density pdf-func numerically and returns the cdf and the inverse cdf as functions.
Parameters:
pdf-func: density, a function of a doublemn: lower bound of the integration (default 0.0), the density should be 0.0 theremx: upper bound of the integration (default 1.0)steps: number of subintervals (default 1000); each is integrated with the Gauss-Kronrod quadratureinterpolator: interpolation of the integrated values, :monotone (default), :linear, :cubic or an interpolation function of fastmath.interpolation (a function of xs and ys)The second arity takes pdf-func and a map with the keys :mn, :mx, :steps and :interpolator; other keys are passed to the quadrature. The range is extended by five subintervals on both sides; the values are normalised so the cdf is 1.0 at the end of the extended range; it is 0.0 below and 1.0 above that range.
Returns a vector [cdf icdf] of two functions of a double. icdf expects a probability from [0, 1], both are interpolations, so they are approximate.
Integrates the density `pdf-func` numerically and returns the cdf and the inverse cdf as functions. Parameters: - `pdf-func`: density, a function of a double - `mn`: lower bound of the integration (default `0.0`), the density should be `0.0` there - `mx`: upper bound of the integration (default `1.0`) - `steps`: number of subintervals (default `1000`); each is integrated with the Gauss-Kronrod quadrature - `interpolator`: interpolation of the integrated values, `:monotone` (default), `:linear`, `:cubic` or an interpolation function of `fastmath.interpolation` (a function of `xs` and `ys`) The second arity takes `pdf-func` and a map with the keys `:mn`, `:mx`, `:steps` and `:interpolator`; other keys are passed to the quadrature. The range is extended by five subintervals on both sides; the values are normalised so the cdf is `1.0` at the end of the extended range; it is `0.0` below and `1.0` above that range. Returns a vector `[cdf icdf]` of two functions of a double. `icdf` expects a probability from `[0, 1]`, both are interpolations, so they are approximate.
(inverse-gaussian mu lambda rng)Inverse Gaussian (Wald) distribution (mu, lambda).
For lambda/mu <= 100 the SSJ InverseGaussianDist is used for everything (same as ssj-continuous). For larger lambda/mu
(the SSJ cdf overflows from about 355 and icdf/samples degenerate) cdf and icdf are computed by [[inverse-gaussian-cdf]]
(log-space second term) and a bracketed root finding in log x; the samples are icdf of uniform numbers.
pdf, moments and bounds come from SSJ.
Inverse Gaussian (Wald) distribution `(mu, lambda)`. For `lambda/mu <= 100` the SSJ `InverseGaussianDist` is used for everything (same as [[ssj-continuous]]). For larger `lambda/mu` (the SSJ cdf overflows from about 355 and `icdf`/samples degenerate) `cdf` and `icdf` are computed by [[inverse-gaussian-cdf]] (log-space second term) and a bracketed root finding in `log x`; the samples are `icdf` of uniform numbers. `pdf`, moments and bounds come from SSJ.
(kolmogorov rng)Kolmogorov distribution, the limit of the scaled Kolmogorov-Smirnov statistic sqrt(n) D_n for large n.
rng is the random generator (nil: a fresh one). Continuous on [0, Inf), mean is 0.8687311606361591 and variance is 0.0677732039638651. Returns a univariate continuous distribution.
Kolmogorov distribution, the limit of the scaled Kolmogorov-Smirnov statistic `sqrt(n) D_n` for large `n`. `rng` is the random generator (`nil`: a fresh one). Continuous on `[0, Inf)`, `mean` is `0.8687311606361591` and `variance` is `0.0677732039638651`. Returns a univariate continuous distribution.
(logarithmic p rng)Logarithmic (log-series) distribution, P(k) = -p^k / (k log(1-p)), k >= 1, 0 < p < 1.
The cdf is the running sum of the pmf terms p^j/j (direct, no cancellation) normalised by -log(1-p); it is 1.0 as soon as the
remaining tail is below 1e-17. icdf scans the same running sum, which makes it the exact smallest k with cdf(k) >= p
and gives a fast inversion sampler (the cost is proportional to the quantile, i.e. around the mean -p/((1-p)log(1-p)) per sample).
The cost of cdf is proportional to min(k, 40/(1-p)).
Logarithmic (log-series) distribution, `P(k) = -p^k / (k log(1-p))`, `k >= 1`, `0 < p < 1`. The cdf is the running sum of the pmf terms `p^j/j` (direct, no cancellation) normalised by `-log(1-p)`; it is 1.0 as soon as the remaining tail is below `1e-17`. `icdf` scans the same running sum, which makes it the exact smallest `k` with `cdf(k) >= p` and gives a fast inversion sampler (the cost is proportional to the quantile, i.e. around the mean `-p/((1-p)log(1-p))` per sample). The cost of `cdf` is proportional to `min(k, 40/(1-p))`.
(mixture distrs weights rng)Finite mixture of the univariate distributions distrs with the weights, see fastmath.random/mixture for the behaviour.
Parameters:
distrs: non-empty sequence of univariate distributionsweights: sequence of finite non-negative numbers of the same count, with a positive sumrng: random generator which selects the component (nil: a fresh one)Returns the mixture, throws ex-info (:type :invalid-input) for invalid arguments.
Finite mixture of the univariate distributions `distrs` with the `weights`, see `fastmath.random/mixture` for the behaviour. Parameters: - `distrs`: non-empty sequence of univariate distributions - `weights`: sequence of finite non-negative numbers of the same count, with a positive sum - `rng`: random generator which selects the component (`nil`: a fresh one) Returns the mixture, throws `ex-info` (`:type :invalid-input`) for invalid arguments.
(multi-normal means covariances rng)Creates a multivariate normal distribution (it wraps Commons MultivariateNormalDistribution, which is its source-object, and the Cholesky factor of the covariances) after validation.
means - sequence of finite numbers, nil: zeros of the dimension of covariances (when both are nil: 2 dimensions),covariances - square, symmetric (within 1e-10 relative to the largest entry), positive definite matrix of finite numbers,
nil: identity matrix of the dimension of means,rng - random generator, nil: a fresh one.Throws ex-info (:type :invalid-input) for invalid arguments and for the size mismatch of means and covariances.
Creates a multivariate normal distribution (it wraps Commons `MultivariateNormalDistribution`, which is its `source-object`, and the Cholesky factor of the covariances) after validation. * `means` - sequence of finite numbers, `nil`: zeros of the dimension of `covariances` (when both are `nil`: 2 dimensions), * `covariances` - square, symmetric (within `1e-10` relative to the largest entry), positive definite matrix of finite numbers, `nil`: identity matrix of the dimension of `means`, * `rng` - random generator, `nil`: a fresh one. Throws `ex-info` (`:type :invalid-input`) for invalid arguments and for the size mismatch of `means` and `covariances`.
(multinomial n ps binomial rng)Multinomial distribution of n (integer, >= 0) trials over the categories with the (relative) probabilities ps.
The probability mass function uses 0 * log 0 = 0 (a category with the probability zero and the count zero does not contribute),
returns 0 for negative or non-integer counts, counts with a wrong sum and a positive count in a category with the probability zero.
Multinomial distribution of `n` (integer, >= 0) trials over the categories with the (relative) probabilities `ps`. The probability mass function uses `0 * log 0 = 0` (a category with the probability zero and the count zero does not contribute), returns 0 for negative or non-integer counts, counts with a wrong sum and a positive count in a category with the probability zero.
(negative-binomial r p rng)(negative-binomial r p rng parameters)(negative-binomial r p rng parameters fit-spec)Negative binomial distribution (r, p): the number of failures before r successes with the success probability p
(r > 0, 0 < p <= 1). The optional parameters (default [:r :p :rng]) is what distribution-parameters reports,
for the constructors accepting other parameters (nbi, nbii), and fit-spec the value of fit-spec (nil: the distribution can't be fitted).
Negative binomial distribution `(r, p)`: the number of failures before `r` successes with the success probability `p` (`r > 0`, `0 < p <= 1`). The optional `parameters` (default `[:r :p :rng]`) is what `distribution-parameters` reports, for the constructors accepting other parameters (`nbi`, `nbii`), and `fit-spec` the value of `fit-spec` (`nil`: the distribution can't be fitted).
(negative-binomial-mean mu r variance rng parameters fit-spec)Negative binomial distribution with the mean mu, the size r and the given variance; reports parameters and fit-spec.
Negative binomial distribution with the mean `mu`, the size `r` and the given `variance`; reports `parameters` and `fit-spec`.
(negative-binomial-point-mass rng)The negative binomial distribution with p = 1: the point mass at 0 (the log-pmf of negative-binomial is NaN there, 0 * log(0)).
The negative binomial distribution with `p = 1`: the point mass at `0` (the log-pmf of [[negative-binomial]] is `NaN` there, `0 * log(0)`).
(normal-inverse-gaussian {:keys [alpha beta mu delta rng]})Normal-inverse Gaussian distribution, in its own (alpha, beta, mu, delta)
parameterization: exactly the lambda = -0.5 special case of
generalized-hyperbolic, reusing its fully numerically-integrated
pdf/cdf/icdf/mean/variance/sampler machinery ([[generalized-hyperbolic-core]])
rather than the backing SSJ NormalInverseGaussianDist class, whose cdf
is not implemented (and whose sample, going through inverseF/icdf,
therefore always threw regardless of RNG/seeding).
Normal-inverse Gaussian distribution, in its own `(alpha, beta, mu, delta)` parameterization: exactly the `lambda = -0.5` special case of [[generalized-hyperbolic]], reusing its fully numerically-integrated pdf/cdf/icdf/mean/variance/sampler machinery ([[generalized-hyperbolic-core]]) rather than the backing SSJ `NormalInverseGaussianDist` class, whose `cdf` is not implemented (and whose `sample`, going through `inverseF`/`icdf`, therefore always threw regardless of RNG/seeding).
(real-discrete-distribution data probabilities rng)Discrete distribution on a finite set of real numbers.
Parameters, validation and the quantile as for integer-discrete-distribution, but data are any numbers other than NaN. pdf needs an exact value of the data (anything else is 0.0), cdf is the step function on the reals. Samples are doubles. Returns a univariate discrete distribution.
Discrete distribution on a finite set of real numbers. Parameters, validation and the quantile as for `integer-discrete-distribution`, but `data` are any numbers other than `NaN`. `pdf` needs an exact value of the data (anything else is `0.0`), `cdf` is the step function on the reals. Samples are doubles. Returns a univariate discrete distribution.
(reciprocal a b rng)Reciprocal (log-uniform) distribution on [a, b], 0 < a < b, with the density 1 / (x log(b / a)).
rng is the random generator (nil: a fresh one). Returns a univariate continuous distribution.
Reciprocal (log-uniform) distribution on `[a, b]`, `0 < a < b`, with the density `1 / (x log(b / a))`. `rng` is the random generator (`nil`: a fresh one). Returns a univariate continuous distribution.
(ssj-continuous nm d rng params)(ssj-continuous nm d rng params fit-spec)Wraps the SSJ continuous distribution d into a distribution object.
Parameters:
nm: keyword, the value of distribution-idd: an SSJ ContinuousDistribution, it is also the source-objectrng: random generator (nil: a fresh one)params: vector of keywords reported by distribution-parametersfit-spec (optional): the fitting specification returned by fit-spec or the keyword naming one in fastmath.fitdistr.fit-specs, nil (default) for a distribution which can't be fittedpdf, cdf, icdf, mean, variance and the bounds are the ones of SSJ, lpdf is the logarithm of the density. A sample is the SSJ quantile of a uniform number from rng. grandom, brandom and set-seed throw UnsupportedOperationException, set-seed! reseeds rng. Returns a univariate continuous distribution.
Wraps the SSJ continuous distribution `d` into a distribution object. Parameters: - `nm`: keyword, the value of `distribution-id` - `d`: an SSJ `ContinuousDistribution`, it is also the `source-object` - `rng`: random generator (`nil`: a fresh one) - `params`: vector of keywords reported by `distribution-parameters` - `fit-spec` (optional): the fitting specification returned by `fit-spec` or the keyword naming one in `fastmath.fitdistr.fit-specs`, `nil` (default) for a distribution which can't be fitted `pdf`, `cdf`, `icdf`, `mean`, `variance` and the bounds are the ones of SSJ, `lpdf` is the logarithm of the density. A sample is the SSJ quantile of a uniform number from `rng`. `grandom`, `brandom` and `set-seed` throw `UnsupportedOperationException`, `set-seed!` reseeds `rng`. Returns a univariate continuous distribution.
(ssj-continuous-no-pdf nm d rng params)Wraps the SSJ continuous distribution d which has no density into a distribution object.
It is ssj-continuous with the pdf replaced by the central difference of the cdf, (cdf(x + 5e-7) - cdf(x - 5e-7)) / 1e-6, so the density is approximate. Parameters and returned value as for ssj-continuous.
Wraps the SSJ continuous distribution `d` which has no density into a distribution object. It is `ssj-continuous` with the `pdf` replaced by the central difference of the cdf, `(cdf(x + 5e-7) - cdf(x - 5e-7)) / 1e-6`, so the density is approximate. Parameters and returned value as for `ssj-continuous`.
(t-noncentral df ncp rng)Noncentral Student t distribution with df degrees of freedom and the noncentrality ncp.
rng is the random generator (nil: a fresh one). pdf and cdf are computed by numerical integration over the chi mixing variable, so they are relatively slow and icdf is found by root finding. mean is NaN for df <= 1, variance is NaN for df <= 1 and ##Inf for 1 < df <= 2. Returns a univariate continuous distribution on the reals.
Noncentral Student t distribution with `df` degrees of freedom and the noncentrality `ncp`. `rng` is the random generator (`nil`: a fresh one). `pdf` and `cdf` are computed by numerical integration over the chi mixing variable, so they are relatively slow and `icdf` is found by root finding. `mean` is `NaN` for `df <= 1`, `variance` is `NaN` for `df <= 1` and `##Inf` for `1 < df <= 2`. Returns a univariate continuous distribution on the reals.
(truncated distr left right)Truncates the distribution distr to [left, right], see fastmath.random/truncated for the behaviour.
Parameters:
distr: a univariate distribution, continuous or discrete on integersleft, right: numbers or nil (the bound of distr)Returns the truncated distribution, throws ex-info (:type :invalid-input) for invalid arguments or an interval with zero probability.
Truncates the distribution `distr` to `[left, right]`, see `fastmath.random/truncated` for the behaviour. Parameters: - `distr`: a univariate distribution, continuous or discrete on integers - `left`, `right`: numbers or `nil` (the bound of `distr`) Returns the truncated distribution, throws `ex-info` (`:type :invalid-input`) for invalid arguments or an interval with zero probability.
(von-mises mu kappa rng)Von Mises distribution on the interval [mu - pi, mu + pi] with the mean direction mu and the concentration kappa, pdf(x) = exp(kappa cos(x - mu)) / (2 pi I0(kappa)).
rng is the random generator (nil: a fresh one). cdf and icdf are obtained by numerical integration of the density. mean is mu and variance is the ordinary (linear) variance on the interval, not the circular variance. Returns a univariate continuous distribution.
Von Mises distribution on the interval `[mu - pi, mu + pi]` with the mean direction `mu` and the concentration `kappa`, `pdf(x) = exp(kappa cos(x - mu)) / (2 pi I0(kappa))`. `rng` is the random generator (`nil`: a fresh one). `cdf` and `icdf` are obtained by numerical integration of the density. `mean` is `mu` and `variance` is the ordinary (linear) variance on the interval, not the circular variance. Returns a univariate continuous distribution.
(wallenius-noncentral-hypergeometric {:keys [ns nf n omega rng]})Wallenius' noncentral hypergeometric distribution.
The number of items of the first kind in a sample of size n drawn one by one without replacement from an urn with ns items of the first and nf of the second kind, where the probability of taking an item is proportional to its weight, omega for the first kind and 1 for the second.
Parameters (a map): ns, nf, n (longs), omega (positive double), rng (nil: a fresh generator). The support is [max(0, n - nf), min(ns, n)]; the probabilities are computed (by numerical integration) for the whole support at construction. Returns a univariate discrete distribution.
Wallenius' noncentral hypergeometric distribution. The number of items of the first kind in a sample of size `n` drawn one by one without replacement from an urn with `ns` items of the first and `nf` of the second kind, where the probability of taking an item is proportional to its weight, `omega` for the first kind and `1` for the second. Parameters (a map): `ns`, `nf`, `n` (longs), `omega` (positive double), `rng` (`nil`: a fresh generator). The support is `[max(0, n - nf), min(ns, n)]`; the probabilities are computed (by numerical integration) for the whole support at construction. Returns a univariate discrete distribution.
(zero-adjusted-beta-binomial {:keys [mu sigma bd nu rng]})Zero-adjusted (hurdle) beta-binomial distribution (gamlss ZABB): zero with the probability nu, otherwise a zero-truncated beta-binomial with the mean mu, the dispersion sigma and bd trials.
Parameters (a map): mu, sigma, nu (doubles), bd (long), rng (nil: a fresh generator). Returns a univariate discrete distribution on [0, bd].
Zero-adjusted (hurdle) beta-binomial distribution (gamlss `ZABB`): zero with the probability `nu`, otherwise a zero-truncated beta-binomial with the mean `mu`, the dispersion `sigma` and `bd` trials. Parameters (a map): `mu`, `sigma`, `nu` (doubles), `bd` (long), `rng` (`nil`: a fresh generator). Returns a univariate discrete distribution on `[0, bd]`.
(zero-adjusted-binomial {:keys [mu sigma bd rng binomial]})Zero-adjusted (hurdle) binomial distribution (gamlss ZABI): zero with the probability sigma, otherwise a zero-truncated binomial with bd trials and the success probability mu.
Parameters (a map): mu, sigma (doubles), bd (long), rng (nil: a fresh generator), binomial (the constructor of the binomial distribution, a function of a map). Returns a univariate discrete distribution on [0, bd].
Zero-adjusted (hurdle) binomial distribution (gamlss `ZABI`): zero with the probability `sigma`, otherwise a zero-truncated binomial with `bd` trials and the success probability `mu`. Parameters (a map): `mu`, `sigma` (doubles), `bd` (long), `rng` (`nil`: a fresh generator), `binomial` (the constructor of the binomial distribution, a function of a map). Returns a univariate discrete distribution on `[0, bd]`.
(zero-adjusted-gamma {:keys [mu sigma nu rng gamma]})Zero-adjusted gamma distribution (gamlss ZAGA): the point mass nu at zero, otherwise a gamma distribution with the mean mu and the coefficient of variation sigma (shape 1 / sigma^2, scale sigma^2 mu).
Parameters (a map): mu, sigma, nu (doubles), rng (nil: a fresh generator), gamma (the constructor of the gamma distribution, a function of a map). Returns a univariate continuous (mixed) distribution on [0, Inf).
Zero-adjusted gamma distribution (gamlss `ZAGA`): the point mass `nu` at zero, otherwise a gamma distribution with the mean `mu` and the coefficient of variation `sigma` (shape `1 / sigma^2`, scale `sigma^2 mu`). Parameters (a map): `mu`, `sigma`, `nu` (doubles), `rng` (`nil`: a fresh generator), `gamma` (the constructor of the gamma distribution, a function of a map). Returns a univariate continuous (mixed) distribution on `[0, Inf)`.
(zero-adjusted-inverse-gaussian {:keys [mu sigma nu rng inverse-gaussian]})Zero-adjusted inverse Gaussian distribution (gamlss ZAIG): the point mass nu at zero, otherwise an inverse Gaussian distribution with the mean mu and lambda = 1 / sigma^2.
Parameters (a map): mu, sigma, nu (doubles), rng (nil: a fresh generator), inverse-gaussian (the constructor of the inverse Gaussian distribution, a function of a map). Returns a univariate continuous (mixed) distribution on [0, Inf).
Zero-adjusted inverse Gaussian distribution (gamlss `ZAIG`): the point mass `nu` at zero, otherwise an inverse Gaussian distribution with the mean `mu` and `lambda = 1 / sigma^2`. Parameters (a map): `mu`, `sigma`, `nu` (doubles), `rng` (`nil`: a fresh generator), `inverse-gaussian` (the constructor of the inverse Gaussian distribution, a function of a map). Returns a univariate continuous (mixed) distribution on `[0, Inf)`.
(zero-adjusted-negative-binomial {:keys [mu sigma nu rng nbi]})Zero-adjusted (hurdle) negative binomial distribution (gamlss ZANBI): zero with the probability nu, otherwise a zero-truncated type I negative binomial (nbi) with the mean mu and the dispersion sigma.
Parameters (a map): mu, sigma, nu (doubles), rng (nil: a fresh generator), nbi (the constructor of the nbi distribution, a function of a map). Returns a univariate discrete distribution on the non-negative integers.
Zero-adjusted (hurdle) negative binomial distribution (gamlss `ZANBI`): zero with the probability `nu`, otherwise a zero-truncated type I negative binomial (`nbi`) with the mean `mu` and the dispersion `sigma`. Parameters (a map): `mu`, `sigma`, `nu` (doubles), `rng` (`nil`: a fresh generator), `nbi` (the constructor of the `nbi` distribution, a function of a map). Returns a univariate discrete distribution on the non-negative integers.
(zero-adjusted-poisson {:keys [mu sigma rng poisson]})Zero-adjusted (hurdle) Poisson distribution (gamlss ZAP): zero with the probability sigma, otherwise a zero-truncated Poisson with the rate mu.
Parameters (a map): mu, sigma (doubles), rng (nil: a fresh generator), poisson (the constructor of the Poisson distribution, a function of a map). Returns a univariate discrete distribution on the non-negative integers.
Zero-adjusted (hurdle) Poisson distribution (gamlss `ZAP`): zero with the probability `sigma`, otherwise a zero-truncated Poisson with the rate `mu`. Parameters (a map): `mu`, `sigma` (doubles), `rng` (`nil`: a fresh generator), `poisson` (the constructor of the Poisson distribution, a function of a map). Returns a univariate discrete distribution on the non-negative integers.
(zero-inflated-beta-binomial {:keys [mu sigma bd nu rng]})Zero-inflated beta-binomial distribution (gamlss ZIBB): the probability nu of an extra zero, otherwise a beta-binomial with the mean mu, the dispersion sigma and bd trials.
Parameters (a map): mu, sigma, nu (doubles), bd (long), rng (nil: a fresh generator). Returns a univariate discrete distribution on [0, bd].
Zero-inflated beta-binomial distribution (gamlss `ZIBB`): the probability `nu` of an extra zero, otherwise a beta-binomial with the mean `mu`, the dispersion `sigma` and `bd` trials. Parameters (a map): `mu`, `sigma`, `nu` (doubles), `bd` (long), `rng` (`nil`: a fresh generator). Returns a univariate discrete distribution on `[0, bd]`.
(zero-inflated-binomial {:keys [mu sigma bd rng binomial]})Zero-inflated binomial distribution (gamlss ZIBI): an extra zero with the probability sigma, otherwise a binomial with bd trials and the success probability mu.
Parameters (a map): mu, sigma (doubles), bd (long), rng (nil: a fresh generator), binomial (the constructor of the binomial distribution, a function of a map). Returns a univariate discrete distribution on [0, bd].
Zero-inflated binomial distribution (gamlss `ZIBI`): an extra zero with the probability `sigma`, otherwise a binomial with `bd` trials and the success probability `mu`. Parameters (a map): `mu`, `sigma` (doubles), `bd` (long), `rng` (`nil`: a fresh generator), `binomial` (the constructor of the binomial distribution, a function of a map). Returns a univariate discrete distribution on `[0, bd]`.
(zero-inflated-negative-binomial {:keys [mu sigma nu rng nbi]})Zero-inflated negative binomial distribution (gamlss ZINBI): an extra zero with the probability nu, otherwise a type I negative binomial (nbi) with the mean mu and the dispersion sigma.
Parameters (a map): mu, sigma, nu (doubles), rng (nil: a fresh generator), nbi (the constructor of the nbi distribution, a function of a map). Returns a univariate discrete distribution on the non-negative integers.
Zero-inflated negative binomial distribution (gamlss `ZINBI`): an extra zero with the probability `nu`, otherwise a type I negative binomial (`nbi`) with the mean `mu` and the dispersion `sigma`. Parameters (a map): `mu`, `sigma`, `nu` (doubles), `rng` (`nil`: a fresh generator), `nbi` (the constructor of the `nbi` distribution, a function of a map). Returns a univariate discrete distribution on the non-negative integers.
(zero-inflated-poisson {:keys [mu sigma rng poisson parameters fit-spec]
:or {parameters [:mu :sigma :rng]
fit-spec fit-specs/zero-inflated-poisson}})Zero-inflated Poisson distribution (gamlss ZIP): an extra zero with the probability sigma, otherwise a Poisson distribution with the rate mu. The mean is (1 - sigma) mu.
Parameters (a map): mu, sigma (doubles), rng (nil: a fresh generator), poisson (the constructor of the Poisson distribution, a function of a map), parameters (vector reported by distribution-parameters, default [:mu :sigma :rng]). icdf is the smallest integer with cdf >= p. Returns a univariate discrete distribution on the non-negative integers.
Zero-inflated Poisson distribution (gamlss `ZIP`): an extra zero with the probability `sigma`, otherwise a Poisson distribution with the rate `mu`. The mean is `(1 - sigma) mu`. Parameters (a map): `mu`, `sigma` (doubles), `rng` (`nil`: a fresh generator), `poisson` (the constructor of the Poisson distribution, a function of a map), `parameters` (vector reported by `distribution-parameters`, default `[:mu :sigma :rng]`). `icdf` is the smallest integer with `cdf >= p`. Returns a univariate discrete distribution on the non-negative integers.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |