Constructs a normal (or multivariate normal) distribution that matches the mean and variance-covariance of the input distribution. This is useful as a quick Gaussian approximation for any distribution whose first two moments are available.

normal_approx(x)

Arguments

x

A dist object to approximate.

Value

A normal distribution (for univariate inputs) or an mvn distribution (for multivariate inputs) with the same mean and variance-covariance as x.

Examples

# Approximate a Gamma(5, 2) with a normal
g <- gamma_dist(shape = 5, rate = 2)
n <- normal_approx(g)
mean(n)
#> [1] 2.5
vcov(n)
#> [1] 1.25