The srchisq_optimize() function generates an optimized proposal for a targeted Chi-squared Distribution.
The proposal can be customized and adjusted based on various options provided by the user.
srchisq_optimize(
df = 2,
xl = NULL,
xr = NULL,
steps = 4091,
proposal_range = NULL,
theta = 0.1,
target_sample_size = 1000,
verbose = FALSE
)The user does not need to store the returned value, because the package internally cashes the proposal. However, we explain here the full returned proposal for advanced users.
A list containing the optimized proposal and related parameters for the specified built-in distribution:
dataA data frame with detailed information about the proposal steps, including:
xThe start point of each step on the x-axis.
s_upperThe height of each step on the y-axis.
p_aPre-acceptance probability for each step.
s_upper_lowerA vector used to scale the uniform random number when the sample is accepted.
areasA numeric vector containing the areas under:
left_tailThe left tail bound.
stepsThe middle steps.
right_tailThe right tail bound.
steps_numberAn integer specifying the number of steps in the proposal.
sampling_probabilitiesA numeric vector with:
left_tailThe probability of sampling from the left tail.
left_and_middleThe combined probability of sampling from the left tail and middle steps.
unif_scalerA numeric scalar, the inverse probability of sampling from the steps part of the proposal (\(\frac{1}{p(lower < x < upper)}\)). Used for scaling uniform random values.
lt_propertiesA numeric vector of 5 values required for Adaptive Rejection Sampling (ARS) in the left tail.
rt_propertiesA numeric vector of 6 values required for ARS in the right tail.
alphaA numeric scalar representing the uniform step area.
tails_methodA string, either "ARS" (Adaptive Rejection Sampling) or "IT" (Inverse Transform), indicating the sampling method for the tails.
proposal_boundsA numeric vector specifying the left and right bounds of the target density.
cnumAn integer representing the cache number of the created proposal in memory.
symmetricA numeric scalar indicating the symmetry point of the proposal, or NULL if not symmetric.
f_paramsA list of parameters for the target density that the proposal is designed for.
is_symmetricA logical value indicating whether the proposal is symmetric.
proposal_typeA string indicating the type of the genedfd proposal:
"custom"The proposal is "custom" when df is provided. Custom proposals are compatible with srchisq_custom.
target_function_areaA numeric scalar estimating the area of the target distribution.
dens_funcA string containing the hardcoded density function.
density_nameA string specifying the name of the target density distribution.
lockAn identifier used for saving and loading the proposal from disk.
(optional) Numeric. degrees of freedom parameter of the Chi-squared Distribution. Defaults to NULL, which implies proposal with df = 2.
Numeric. Left truncation bound for the target distribution. Defaults to -Inf, representing no left truncation.
Numeric. Right truncation bound for the target distribution. Defaults to Inf, representing no right truncation.
(optional) Integer. Desired number of steps in the proposal. Defaults to NULL, which means the number of steps is determined automatically during optimization.
(optional) Numeric vector. Specifies the range for optimizing the steps part of the proposal. Defaults to NULL, indicating automatic range selection.
Numeric. A parameter for proposal optimization. Defaults to 0.1.
(optional) Integer. Target sample size for proposal optimization. Defaults to 1000.
Boolean. If TRUE, detailed optimization information, including areas and steps, will be displayed. Defaults to FALSE.
When srchisq_optimize() is explicitly called:
A proposal is created and cached. If no parameters are provided, a standard proposal is created with df = 2.
Providing df creates a custom proposal, which is cached for use with srchisq_custom().
The optimization process can be controlled via parameters such as steps, proposal_range, or
theta. If no parameters are provided, the proposal is optimized via brute force based on the.
target_sample_size.
srchisq_custom: Function to sample from a custom proposal genedfd by srchisq_optimize().
# Genedf custom proposal that with df = 2, that has 4096 steps
scalable_proposal <- srchisq_optimize(steps = 4096)
# Genedf custom proposal that with df = 4
scalable_proposal <- srchisq_optimize(df = 4)
Run the code above in your browser using DataLab