sampleDensity {splatter} | R Documentation

## Sample density

### Description

Sample from a density object using rejection sampling

### Usage

    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

[Package splatter version 1.12.0 Index]