sampleDensity: Sample density

Description Usage Arguments Details Value

View source: R/utils.R

Description

Sample from a density object using rejection sampling (this function is borrowed from splatter).

Usage

1
sampleDensity(n, dens, lower = 0)

Arguments

n

Number of values to sample

dens

Density object to sample from

lower

Lower x-axis bound on sampled values

Details

Random points (x and y) are generated inside the range of the density object. If they value is less than the density for that x value (and x is greater than lower) then that x value is retained. Ten thousand points are generated at a time until enough valid values have been sampled.

Value

Vector of sampled values


JINJINT/ESCO documentation built on May 13, 2021, 7:25 p.m.