Generates samples from a Gaussian kernel density estimate of a numeric vector.

rgaussiandens(x, n = length(x), p = 1, seed = 32124)

Arguments

x

Numeric vector to estimate density from.

n

Integer. Number of samples per replicate (default: length of x).

p

Integer. Number of replicates (default: 1).

seed

Integer. Random seed for reproducibility (default: 123).

method

Character. Sampling method: "antithetic" or "traditional".

Value

A vector or matrix of samples from the estimated density.

Examples

x <- rnorm(10)
rgaussiandens(x, n = 10, p = 3)
#>             [,1]       [,2]       [,3]
#>  [1,] -0.2201135 -0.5132901  0.2264192
#>  [2,] -0.2829092 -0.4697736  0.9784991
#>  [3,] -0.5348349 -2.1589900 -1.1324550
#>  [4,]  0.8101387 -0.6655741  0.3041711
#>  [5,] -1.9037032 -0.2946513 -0.2593461
#>  [6,]  0.3151243 -0.1831067 -1.4839787
#>  [7,] -1.2674475 -3.0390254 -2.9418626
#>  [8,] -0.2587634 -0.2318015 -1.1045857
#>  [9,] -0.1346452  0.2664400 -0.6504609
#> [10,]  0.1245560  0.1104622 -0.6789287