Skip to contents

The srgamma_optimize() function generates an optimized proposal for a targeted Gamma distribution. The proposal can be customized and adjusted based on various options provided by the user.

Usage

srgamma_optimize(
  shape = NULL,
  rate = NULL,
  scale = NULL,
  xl = NULL,
  xr = NULL,
  steps = 4091,
  proposal_range = NULL,
  theta = 0.1,
  target_sample_size = 1000,
  verbose = FALSE
)

Arguments

shape

(optional) Numeric. The shape parameter (\(\alpha\)) of the Gamma distribution. Defaults to 1.

rate

(optional) Numeric. The rate parameter (\(\beta\)) of the Gamma distribution. Defaults to 1.

scale

(optional) Numeric. The scale parameter of the Gamma distribution. Defaults to 1.

xl

Numeric. Left truncation bound for the target distribution. Defaults to 0, representing no left truncation.

xr

Numeric. Right truncation bound for the target distribution. Defaults to Inf, representing no right truncation.

steps

(optional) Integer. Desired number of steps in the proposal. Defaults to 4091.

proposal_range

(optional) Numeric vector. Specifies the range for optimizing the steps part of the proposal. Defaults to NULL, indicating automatic range selection.

theta

Numeric. A parameter for proposal optimization. Defaults to 0.1.

target_sample_size

(optional) Integer. Target sample size for proposal optimization. Defaults to 1000.

verbose

Boolean. If TRUE, detailed optimization information, including areas and steps, will be displayed. Defaults to FALSE.

Value

A list containing the optimized proposal and related parameters for the specified Gamma distribution. The proposal is also cached for internal use.

data

Detailed information about the proposal steps, including x, s_upper, p_a, and s_upper_lower.

areas

The areas under the left tail, steps, and right tail of the proposal distribution.

steps_number

The number of steps in the proposal.

f_params

The parameters (shape and rate) of the Gamma distribution.

Details

When srgamma_optimize() is explicitly called:

  • A proposal is created and cached. If no parameters are provided, a standard proposal is created with shape = 1 and rate = 1.

  • Providing shape and rate creates a custom proposal, which is cached for use with srgamma_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.

See also

srgamma_custom: Function to sample from a custom proposal generated by srgamma_optimize().

Examples

# Generate a standard proposal with shape = 1 and rate = 1
standard_proposal <- srgamma_optimize()

# Generate a custom proposal with shape = 2 and rate = 3
custom_proposal <- srgamma_optimize(shape = 2, rate = 3)