library(tidyverse)
library(patchwork)
library(ggalt)
library(ggbeeswarm)
library(gglogspline) # git.rud.is/hrbrmstr/gglogspline

# some IRL sample data from our (Rapid7) measurements of the uptime of
# Exim mail servers using hping3
if (!file.exists("~/Data/ld-exim-sample.txt.gz")) {
  download.file(
    url = "https://rud.is/dl/ld-exim-sample.txt.gz", 
    destfile = "~/Data/ld-exim-sample.txt.gz"
  )
}

con <- gzfile("~/Data/ld-exim-sample.txt.gz")

tibble(
  val = scan(con)
) -> xdf
## Read 20000 items

close(con)

summary(xdf$val)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    1.00    9.02   20.94   21.71   32.91   59.29

(ggplot(xdf, aes(val)) + geom_histogram(bins = 100) + labs(title = "hist")) +
  (ggplot(xdf, aes(val)) + geom_density() + labs(title = "dens"))


(ggplot(xdf, aes(val)) + geom_histogram(bins = 100) + labs(title = "hist")) +
  (ggplot(xdf, aes(val)) + stat_logspline() + labs(title = "logspline"))


(ggplot(xdf, aes(val)) + geom_bkde(bandwidth = 0.5) + labs(title = "bkde")) +
  (ggplot(xdf, aes(val)) + stat_logspline() + labs(title = "logspline"))