[Maturing]

The density(), mean(), and variance() methods are approximate as they are based on numerical derivatives.

dist_transformed(dist, transform, inverse)

Arguments

dist

A univariate distribution vector.

transform

A function used to transform the distribution. This transformation should be monotonic over appropriate domain.

inverse

The inverse of the transform function.

Examples

# Create a log normal distribution
dist <- dist_transformed(dist_normal(0, 0.5), exp, log)
density(dist, 1) # dlnorm(1, 0, 0.5)
#> [1] 0.7978846
cdf(dist, 4) # plnorm(4, 0, 0.5)
#> [1] 0.9972194
quantile(dist, 0.1) # qlnorm(0.1, 0, 0.5)
#> [1] 0.5268835
generate(dist, 10) # rlnorm(10, 0, 0.5)
#> [[1]]
#>  [1] 1.2215165 0.9405469 0.9649562 2.8515628 1.9368081 1.8226281 0.6764226
#>  [8] 0.8019266 0.8842512 1.2006896
#>