Description Usage Format Value Public Methods Private Methods Public fields Active bindings Methods Examples
ARS class providing object with methods for communication with R6
ARS class providing object with methods for communication with R6
1 |
R6Class
object.
Object of R6Class
with methods to generate adaptive rejection sampling
sample(n, init_l, init_r, squeeze)
This method samples n points from using adaptive rejection sampling. User may pick two initalizing points, init_l and init_r which represent data points to start at. Useful if -1 and 1 are far from the pdf, i.e rnorm(mean=3000, sd=1)
f(x)
This method calculates our funx observation at a given x
plot_sampdist()
This method plots our normalized envelope function
calc_sampdist()
This method calculates the sampling distribution from a uniform distribution
plot_samples()
This method plots our samples in a histogramm, with a blue line highlighting the median value
s()
This method calculates the envelope or sampling function
h(x)
This method calculates the log of our funx at a given point x
init_hprim()
This method intializes our hprim values
init_hval()
This method initalizes our h values
init_scdf()
This method initalizes our cdf under the upper hull
init_u()
This method initializes our upper hull values
init_y()
This method initalizes our y values
l(p)
This method is a function that returns the slope of a lowerhull line given a point p
u(p)
This method is a function that returns the slope of a upperhull line given a point p
sampl_exph()
This method samples from our exp(h values)
update(y, hy, hy_prim)
This method updates our private variables after an interation
self$f
Desnity function we want to sample from
self$var_max
Upper bound on function we want to sample from
self$var_min
Lower bound on function we want to sample from
private$h_prims
A R6 namedVector that contains h'(x)
private$h_vals
A R6 namedVector that contains h(x)
private$s_cdfs
A R6 namedVector that contains each interval's CDF
private$u_vals
A R6 namedVector that contains u(x)
private$x
a vector of x values that are our sample values. Empty unless sample() run
private$y
a vector of y values that begins to increase once sample() is run
private$z
a vector of z values, or intersection points, that begins to increase once sample() is run
self$f
Desnity function we want to sample from
self$var_max
Upper bound on function we want to sample from
self$var_min
Lower bound on function we want to sample from
private$h_prims
A R6 namedVector that contains h'(x)
private$h_vals
A R6 namedVector that contains h(x)
private$s_cdfs
A R6 namedVector that contains each interval's CDF
private$u_vals
A R6 namedVector that contains u(x)
private$x
a vector of x values that are our sample values. Empty unless sample() run
private$y
a vector of y values that begins to increase once sample() is run
private$z
a vector of z values, or intersection points, that begins to increase once sample() is run
new()
ars$new(funx, D = c(-Inf, Inf), ...)
funx
a function we want to sample from
D
a vector of length 2 of numbers for bounds of function
calc_sampdist()
ars$calc_sampdist()
sample()
ars$sample(n = 1000, init_l = -1, init_r = 1, squeeze = TRUE)
plot_samples()
ars$plot_samples()
plot_sampdist()
ars$plot_sampdist()
plot_u_l()
ars$plot_u_l()
clone()
The objects of this class are cloneable with this method.
ars$clone(deep = FALSE)
deep
Whether to make a deep clone.
1 2 3 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.