# NOT RUN {
# Simulate data
set.seed(123)
type = 'skewed_unimodal'
n = 500
y = rmixnorm(n, type = type)
# Compute the essential histogram
eh = essHistogram(y, plot = FALSE)
# Plot results
# compute oracle density
x = sort(y)
od = dmixnorm(x, type = type)
# compare with orcle density
plot(x, od, type = "l", xlab = NA, ylab = NA, col = "red", main = type)
lines(eh)
legend("topleft", c("Oracle density", "Essential histogram"),
lty = c(1,1), col = c("red", "black"))
# }
Run the code above in your browser using DataLab