Generic method for obtaining the conditional distribution of a distribution object x given condition P.

conditional(x, P, ...)

Arguments

x

The empirical distribution object.

P

The predicate function to condition x on

...

additional arguments to pass into P

Value

A distribution object for the conditional distribution.

Examples

# \donttest{
d <- empirical_dist(1:100)
# condition on values greater than 50
d_gt50 <- conditional(d, function(x) x > 50)
mean(d_gt50)
#> [1] 75.5
# }