View source: R/helper_functions.R
g_inv_approx | R Documentation |
Compute the inverse function of a transformation g
based on a grid search.
g_inv_approx(g, t_grid)
g |
the transformation function |
t_grid |
grid of arguments at which to evaluate the transformation function |
A function which can be used for evaluations of the (approximate) inverse transformation function.
# Sample some data:
y = rpois(n = 500, lambda = 5)
# Empirical CDF transformation:
g_np = g_cdf(y, distribution = 'np')
# Grid for approximation:
t_grid = seq(1, max(y), length.out = 100)
# Approximate inverse:
g_inv = g_inv_approx(g = g_np, t_grid = t_grid)
# Check the approximation:
plot(t_grid, g_inv(g_np(t_grid)), type='p')
lines(t_grid, t_grid)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.