dist_transformed(dist, transform, inverse)
A univariate distribution vector.
A function used to transform the distribution. This transformation should be monotonic over appropriate domain.
The inverse of the transform
function.
The density()
, mean()
, and variance()
methods are approximate as
they are based on numerical derivatives.
# 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] 0.3776817 1.8587150 1.2378836 1.4251320 0.7333293 0.4738132 1.0466119
#> [8] 2.8619956 1.4276296 2.6102480
#>