Transform a grid distribution
map_grid.RdThe distribution of f(X) on the same step. Each point's mass moves to
f(x); a value between two points is split between them so its mean is
kept. The mean is therefore always exact, and the whole distribution is
exact when every value lands on a point.
Arguments
Value
A list with grid (a grid_distribution) and on_points
(whether every value landed on a grid point).
Examples
x <- grid_distribution(1, c(0.2, 0.3, 0.3, 0.2))
r <- map_grid(x, function(v) min(max(v - 1, 0), 1))
r$grid@probs
#> [1] 0.5 0.5
r$on_points
#> [1] TRUE