param_random: Create a Value Sampler for Random Parameters

View source: R/net.inputs.R

param_randomR Documentation

Create a Value Sampler for Random Parameters

Description

This function returns a 0 argument function that can be used as a generator function in the random.params argument of the param.net function.

Usage

param_random(values, prob = NULL)

Arguments

values

A vector of values to sample from.

prob

A vector of weights to use during sampling. If NULL, all values have the same probability of being picked (default = NULL).

Value

A 0 argument generator function to sample one of the values from the values vector.

See Also

param.net and generate_random_params

Examples

# Define function with equal sampling probability
a <- param_random(1:5)
a()

# Define function with unequal sampling probability
b <- param_random(1:5, prob = c(0.1, 0.1, 0.1, 0.1, 0.6))
b()


EpiModel documentation built on July 9, 2023, 5:21 p.m.