InvMethod {BaPreStoPro} | R Documentation |
Algorithm to sample from cumulative distribution function, if no inverse function is analytically available.
InvMethod(Fun, len, candArea, grid = 1e-05, method = c("vector", "free"))
Fun |
cumulative distribution function |
len |
number of samples |
candArea |
candidate area |
grid |
fineness degree |
method |
vectorial ("vector") or not ("free") |
Devroye, L. (1986). Non-Uniform Random Variate Generation. New York: Springer.
test <- InvMethod(function(x) pnorm(x, 5, 1), 1000, candArea = c(0, 10), method = "free") plot(density(test)) curve(dnorm(x, 5, 1), col = 2, add = TRUE)