sampleFromDensity {RVCompare}R Documentation

Get sample given the density function

Description

Returns an array with samples given the probability density function.

Usage

sampleFromDensity(density, nSamples, xlims, nIntervals = 1e+05)

Arguments

density

the probability density function.

nSamples

the number of samples to generate.

xlims

the domain of definition of the random variable.

nIntervals

(optional, default = 1e4) the number of intervals from which to draw samples. A higher value implies more accuracy but also more computation time.

Value

Returns an array of samples.

Examples

normDens <- normalDensity(0,1)
samples <- sampleFromDensity(normDens, 1e4, c(-4,4))
hist(samples,  breaks=20)

[Package RVCompare version 0.1.8 Index]