Skip to contents

Density, CDF, quantile, and seeded sampling for the 13 distribution families ported from HEC.FDA.Statistics. Families are addressed by name with a numeric parameter vector in the core factory's order (the same order fixtures/distributions/*.json use), e.g. Normal = c(mean, sd, sample_size), Uniform = c(min, max, sample_size), Triangular = c(min, most_likely, max, sample_size).

Usage

dist_pdf(dist, params, x)

dist_cdf(dist, params, x)

dist_quantile(dist, params, p)

dist_sample(dist, params, n, seed)

Arguments

dist

distribution family name, e.g. "Normal", "LogPearson3", "Triangular".

params

numeric parameter vector in factory order.

x, p

numeric vector of evaluation points / probabilities.

n

number of draws.

seed

integer seed.

Value

numeric vector.

Details

Sampling draws inverse_cdf(u) over the seeded generator stream (rng_sequence()), the same chain the ported Monte Carlo computes use, so seeded draws match Python and the upstream C#.

Examples

dist_cdf("Normal", c(0, 1, 1), 0) # 0.5
#> [1] 0.5
dist_sample("Normal", c(0, 1, 1), n = 3L, seed = 1234L)
#> [1] -0.2553114  1.2586896 -0.4695057