genSample.MarginalScalar {spup}R Documentation

Generating Monte Carlo sample from an uncertain object of a class 'MarginalScalar'

Description

Function that runs Monte Carlo simulations for MarginalScalar class objects.

Usage

## S3 method for class 'MarginalScalar'
genSample(UMobject, n, samplemethod, p = 0, asList = TRUE, ...)

Arguments

UMobject

uncertain object defined using defineUM().

n

Integer. Number of Monte Carlo realizations.

samplemethod

"randomSampling" or "stratifiedSampling".

p

A vector of quantiles. Optional. Only required if sample method is "stratifiedSampling".

asList

logical. If asList = TRUE returns list of all samples as a list. If asList = FALSE returns samples in a format of distribution parameters in UMobject.

...

Additional parameters.

Details

"stratifiedSampling" Number of samples (n) must be dividable by the number of quantiles to assure each quantile is evenly represented.

Value

A Monte Carlo sample of uncertain input of a class of distribution parameters.

Author(s)

Kasia Sawicka

Examples


set.seed(12345)
# Example 1
scalarUM <- defineUM(uncertain = TRUE, distribution = "norm", distr_param = c(10, 1))
scalar_sample <- genSample(scalarUM, n = 10, samplemethod = "randomSampling")

# Example 2
scalarUM <- defineUM(uncertain = TRUE, distribution = "beta", distr_param = c(10, 1, 2))
scalar_sample <- genSample(scalarUM, n = 10, samplemethod = "stratifiedSampling", p = 0:5/5)


[Package spup version 1.4-0 Index]