Skip to contents

Construct a distribution from its family name and parameter vector. The result is a lightweight object accepted by dist_pdf(), dist_cdf(), dist_quantile(), dist_random(), dist_moments(), and friends. The 38 families of the USACE-RMC Numerics library that take a flat parameter vector are all supported, from Normal and Gumbel through GeneralizedNormal (the three-parameter LogNormal) and KappaFour; distribution_names() returns them. The five composite families it lists under "structured" have no flat parameter vector and are built by dist_truncated(), dist_mixture(), dist_competing_risks(), dist_empirical(), and dist_kde() instead.

Usage

distribution(family, params)

Arguments

family

the distribution family name, e.g. "Normal", "LogNormal", "Gumbel", "GeneralizedExtremeValue", "GeneralizedNormal".

params

numeric vector of parameters, in constructor order.

Value

An object of class corehydro_dist.

Details

Parameters are positional, in the same order as the C# constructor for the family (for example Normal takes c(mean, sd) and GeneralizedExtremeValue takes c(location, scale, shape)). Use dist_params() on a constructed object to see the parameter names.

See also

dist_fit() to estimate one from data, distribution_names().

Examples

d <- distribution("Normal", c(100, 15))
d
#> <corehydro_dist> Normal(µ = 100, σ = 15)
dist_cdf(d, 100)
#> [1] 0.5

# GeneralizedNormal is the three-parameter LogNormal: at shape 0 it is the Normal.
gn <- distribution("GeneralizedNormal", c(100, 15, 0))
dist_cdf(gn, 100)
#> [1] 0.5