empirical_dist object.R/empirical_dist.R
density.empirical_dist.RdMethod for obtaining the pdf of a empirical_dist object.
# S3 method for class 'empirical_dist'
density(x, ...)A function computing the empirical PMF at given points.
sort tibble lexicographically and do a binary search to find upper
and lower bound in log(nobs(x)) time.
ed <- empirical_dist(c(1, 2, 2, 3, 3, 3))
f <- density(ed)
f(2) # 2/6
#> [1] 0.3333333
f(3, log = TRUE) # log(3/6)
#> [1] -0.6931472