Skip to contents

empirical(x) describes a random variable by a sample of its values, one per scenario, instead of by a distribution. Pass it to rand_var(), as in rand_var(m, "demand", empirical(x)). The length of the sample sets the number of scenarios.

Usage

empirical(data)

Arguments

data

The sample: a numeric vector without NA, one value per scenario.

Value

An object of class quicopt_empirical, for rand_var() or set_distribution(). It can also be an element of the sources of a program().

Details

This is how to use a distribution the package has no function for: draw a sample in R, for example with rlnorm(), and pass it to empirical().

The samples of a model are read side by side, the i-th value of each in scenario i, so values observed together stay together. set_empirical() does this for every column of a data frame.

A sample is fixed data. If it was drawn in R, R's set.seed() determines it, not the model's seed, and resample() does not draw it again.

Examples

set.seed(1)
m <- model()
demand <- rand_var(m, "demand", empirical(rlnorm(500, log(100), 0.3)))   # lognormal