Conditional Distributions
slice.Rd
slice_left()
removes probability to the left of some breakpoint,
conditioning the random variable to be bigger than the breakpoint.
slice_right()
does the opposite: removes probability to the right,
conditioning to be smaller than the breakpoint.
Usage
slice_left(distribution, breakpoint, include = TRUE, ...)
slice_right(distribution, breakpoint, include = TRUE, ...)
Arguments
- distribution
Distribution to slice.
- breakpoint
Point at which to slice (single numeric).
- include
Logical; should the breakpoint be removed as well? This is only realistically relevant if the breakpoint has a non-zero probability of occurrence.
- ...
Other arguments to pass to specific methods. Currently unused.
Examples
library(magrittr)
distionary::dst_norm(0, 1) %>%
slice_left(-2) %>%
slice_right(2) %>%
distionary::enframe_cdf(at = -3:3)
#> # A tibble: 7 × 2
#> .arg cdf
#> <int> <dbl>
#> 1 -3 0
#> 2 -2 0
#> 3 -1 0.142
#> 4 0 0.5
#> 5 1 0.858
#> 6 2 1
#> 7 3 1
d <- distionary::dst_empirical(c(2, 5, 6, 9, 11))
d %>%
slice_left(5) %>%
distionary::eval_pmf(at = 5)
#> [1] 0
d %>%
slice_left(5, include = TRUE) %>%
distionary::eval_pmf(at = 5)
#> [1] 0