Learn R Programming

YEAB (version 1.0.6)

sample_from_density: Sample from a density estimate

Description

Sample from a density estimate

Usage

sample_from_density(x, n)

Value

A sample with distribution close to x

Arguments

x

A numeric variable from a (un)known distribution

n

Number of samples to return

Examples

Run this code

x <- rnorm(1000)
y <- sample_from_density(x, 1000)

hist(x,
  breaks = 30,
  freq = FALSE,
  col = "grey",
  main = "Original data"
)

Run the code above in your browser using DataLab