Truncate a distribution
dist_truncated(dist, lower = -Inf, upper = Inf)
dist |
The distribution(s) to truncate. |
lower, upper |
The range of values to keep from a distribution. |
Note that the samples are generated using inverse transform sampling, and the means and variances are estimated from samples.
dist <- dist_truncated(dist_normal(2,1), lower = 0) dist mean(dist) variance(dist) generate(dist, 10) density(dist, 2) density(dist, 2, log = TRUE) cdf(dist, 4) quantile(dist, 0.7) if(requireNamespace("ggdist")) { library(ggplot2) ggplot() + ggdist::stat_dist_halfeye( aes(y = c("Normal", "Truncated"), dist = c(dist_normal(2,1), dist_truncated(dist_normal(2,1), lower = 0))) ) }
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.