Rejection sampling from the (pseudo) pdf f in the interval between x_min and x_max. Returns n samples. Note that values of f below 0 are capped to zero
numeric vector, sample of size n drawn from the (pseudo) pdf specified by f
Arguments
f
function. (pseudo) pdf from which the sample is drawn
x_min
number, lower limit of the examined interval
x_max
number, upper limit of the examined interval
n
integer. number of samples drawn
f_max
number, maximum value of f in the interval from x_min to x_max. If f attains values larger than f_max a warning is throw, f_max is adjusted, and sampling is started again
max_try
maximum number of tries in the rejection sampling algorithm. If more tries are needed, an error is thrown. If this is the case, inspect of your function f is well-defined and positive, and if f_max provides a reasonable upper bound on it. Adjust max_try if you are certain that both is the case, e.g. if f is highly irregular.
See Also
p3_var_rate() for the derived variable rate Poisson point process implementation.