conditional.dist: Method for obtaining the condition distribution, 'x | P(x)',...

View source: R/dist.R

conditional.distR Documentation

Method for obtaining the condition distribution, x | P(x), of dist object x.

Description

Falls back to MC: materializes x via ensure_realized() and then conditions on the resulting empirical distribution.

Usage

## S3 method for class 'dist'
conditional(x, P, n = 10000L, ...)

Arguments

x

The distribution object.

P

The predicate function to condition the distribution on

n

The number of samples to generate for the MC estimate of the conditional distribution x | P. Defaults to 10000.

...

additional arguments to pass into P.

Value

An empirical_dist approximating the conditional distribution.

Examples


set.seed(1)
x <- exponential(1)
# Condition on X > 2
x_gt2 <- conditional(x, function(t) t > 2)
mean(x_gt2)


algebraic.dist documentation built on Feb. 27, 2026, 5:06 p.m.