rmap: Generic method for applying a map 'f' to distribution object...

View source: R/generic_dist.R

rmapR Documentation

Generic method for applying a map f to distribution object x.

Description

Generic method for applying a map f to distribution object x.

Usage

rmap(x, g, ...)

Arguments

x

The distribution object.

g

The function to apply.

...

Additional arguments to pass into g.

Value

A distribution representing the push-forward of x through g.

Examples


d <- empirical_dist(1:20)
d_sq <- rmap(d, function(x) x^2)
mean(d_sq)  # E[X^2] for uniform 1..20


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