sampleDistribution: Sample distribution functions

View source: R/sampleDistribution.R

sampleDistributionR Documentation

Sample distribution functions

Description

Generates random samples from distribution functions/objects

Usage

sampleDistribution(dist, nSamples = 10)

Arguments

dist

distribution object to sample

nSamples

'integer' size of sample

Details

sampleDistribution can be used for any distribution object generated by makeDistribution or by functions in the distr package. It is a wrapper around dist::r.

Value

a numeric vector containing the sample

Author(s)

Jens Åström

See Also

makeDistribution

Examples

myDist <- makeDistribution(input = "logNormal", distParams = list("mean" = 1, "sd" = 0.2))
sampleDistribution(dist = myDist, nSamples = 10)

myDist <- makeDistribution(input = "Poisson", distParams = list("lambda" = 3))
sampleDistribution(myDist, 10)

myProbs <- data.frame("est" = c(0.2, 0.23, 0.34, 0.4), "probs" = c(0.1, 0.4, 0.4, 0.1 ))
myDist <- makeDistribution(myProbs)
sampleDistribution(myDist, 10)

codaSamples <- rnorm(10000, mean = 0.87, sd = 0.3)
myDist <- makeDistribution(codaSamples)
mean(sampleDistribution(myDist, 10000))


NINAnor/NIcalc documentation built on Oct. 26, 2023, 9:37 a.m.