ParameterSets are passed to a Distribution$new constructor when creating a custom probability distribution that takes parameters.

Value

An R6 object of class ParameterSet.

Constructor

ParameterSet$new(id, value, support, settable, updateFunc = NULL, description = NULL)

Constructor Arguments

ArgumentTypeDetails
idcharacterunique one-word identifier.
valuenumericinitial parameter value.
supportnumericrange of values parameter can take.
settablelogicalif TRUE the parameter is printed. See Details.
updateFunc = NULLfunctionevaluated to update parameter. See Details.
description = NULLcharacteroptional description of parameter.

Constructor Details

An R6 ParameterSet is required to construct a custom Probability Distribution that takes parameters. This constructor ensures that the correct format of parameters is supplied to the distribution.

Every argument can either be given as the type listed above or as a list of that type. If arguments are provided as a list, then each argument must be of the same length list, with values as NULL where appropriate. See examples for more.

Each parameter requires a unique one-word id that is used to get and set parameters after construction. The parameterisation of the distribution is determined by the parameters that have settable = TRUE, this is a slightly confusing term as it actually refers to a parameter being 'machine-settable'. Here it just means that the given parameter is used in construction and therefore will be included in a call to $print. updateFunc is used to update the parameters not used in the parameterisation. These should be given as a function that could be understood in the body of a Distribution and should start with function(self), see examples.

Internally after calling $setParameterValue, $update is called to update all parameters with a non-NA updateFunc.

Public Methods

MethodLink
print(hide_cols = c("updateFunc","settable"))print.ParameterSet
update()update.ParameterSet
parameters(id = NULL)parameters
getParameterSupport(id, error = "warn")getParameterSupport
getParameterValue(id, error = "warn")getParameterValue
setParameterValue(..., lst = NULL, error = "warn")setParameterValue
merge(y, ...)merge.ParameterSet
as.data.table()as.data.table

See also

Examples

id = list("prob", "size") value = list(0.2, 5) support = list(set6::Interval$new(0,1), set6::PosNaturals$new()) settable = list(TRUE, TRUE) description = list("Probability of success",NULL) ps = ParameterSet$new(id, value, support, settable, description = description) ps$parameters()
#> id value support description #> 1: prob 0.2 [0,1] Probability of success #> 2: size 5.0 ℕ+ None
ps$getParameterValue("prob")
#> [1] 0.2
#> [0,1]
id = list("rate", "scale") value = list(1, 1) support = list(set6::PosReals$new(), set6::PosReals$new()) settable = list(TRUE, FALSE) updateFunc = list(NULL, function(self) 1/self$getParameterValue('rate')) description = list("Arrival rate","Scale parameter") ps = ParameterSet$new(id, value, support, settable, updateFunc, description) ps$parameters(id = "rate")
#> id value support settable description updateFunc #> 1: rate 1 <PosReals> TRUE Arrival rate NA
ps$setParameterValue(rate = 2) # Automatically calls $update ps$getParameterValue("scale") # Auto-updated to 1/2
#> [1] 0.5