slice: Conditional Distributions

slice_leftR Documentation

Conditional Distributions

Description

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.

Value

A conditional distribution.

Examples

library(magrittr)
distionary::dst_norm(0, 1) %>%
  slice_left(-2) %>%
  slice_right(2) %>%
  distionary::enframe_cdf(at = -3:3)

d <- distionary::dst_empirical(c(2, 5, 6, 9, 11))
d %>%
  slice_left(5) %>%
  distionary::eval_pmf(at = 5)
d %>%
  slice_left(5, include = TRUE) %>%
  distionary::eval_pmf(at = 5)

vincenzocoia/distplyr documentation built on March 5, 2024, 9:45 p.m.