## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")

## ----setup--------------------------------------------------------------------
library(DPrivStats)
set.seed(11)

## -----------------------------------------------------------------------------
budget <- new_privacy_budget(epsilon = 4.0, delta = 1e-6, composition = "rdp")

if (can_spend(budget, 1.5)) {
  budget <- spend(budget, 1.5, "mean income by region table")
}

if (can_spend(budget, 1.5)) {
  budget <- spend(budget, 1.5, "education histogram")
}
budget

## -----------------------------------------------------------------------------
data(example_microdata)
h <- dp_histogram(example_microdata$age, epsilon = 1.0,
                  breaks = seq(10, 90, by = 10), normalize = TRUE)
h$estimate # already non-negative by construction

## -----------------------------------------------------------------------------
eps_seq <- c(1.5, 1.5, 1.0)
compare_composition(eps_seq, delta = 1e-6)

## -----------------------------------------------------------------------------
laplace_plr_tail(c(0, 3, 6), epsilon = 1.0)

