sampleFromDensity | R Documentation |
Returns an array with samples given the probability density function.
sampleFromDensity(density, nSamples, xlims, nIntervals = 1e+05)
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. |
Returns an array of samples.
normDens <- normalDensity(0,1)
samples <- sampleFromDensity(normDens, 1e4, c(-4,4))
hist(samples, breaks=20)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.