Extract probability density function from vector of samples

extract_pdf(x, support = NULL, n_density = 2^7)

Arguments

x

Vector of samples from a distribution.

support

Vector of length 2 corresponding to the range of the distribution. Can be NULL.

n_density

Number of equally spaced points at which the density is to be estimated (better to use a power of 2).

Value

Dataframe with columns: Value, Density.

Examples

extract_pdf(rnorm(1e3)) %>% head()
#> Warning: support is NULL, taking the range: -2.88077268629519, 3.32435966598453
#>       Value     Density
#> 1 -2.880773 0.005950737
#> 2 -2.831913 0.007518176
#> 3 -2.783054 0.009442031
#> 4 -2.734195 0.011726853
#> 5 -2.685335 0.014353178
#> 6 -2.636476 0.017279086