Given a constructed DPMech-class, complete with target function and sensitivityNorm, and an oracle for producing records, samples the sensitivity of the target function to set the mechanism's sensitivity.

sensitivitySampler(object, oracle, n, m = NA_integer_, gamma = NA_real_)



an object of class DPMech-class.


a source of random databases. A function returning: list, matrix/data.frame (data in rows), numeric/character vector of records if given desired length > 1; or single record given length 1, respectively a list element, a row/named row, a single numeric/character. Whichever type is used should be expected by object@target.


database size scalar positive numeric, integer-valued.


sensitivity sample size scalar positive numeric, integer-valued.


RDP privacy confidence level.


object with updated gammaSensitivity slot.


Benjamin I. P. Rubinstein and Francesco Ald. "Pain-Free Random Differential Privacy with Sensitivity Sampling", accepted into the 34th International Conference on Machine Learning (ICML'2017), May 2017.


## Simple example with unbounded data hence no global sensitivity. f <- function(xs) mean(xs) m <- DPMechLaplace(target = f, dims = 1) m@sensitivity ## Inf
#> [1] Inf
m@gammaSensitivity ## NA as Laplace is naturally eps-DP
#> [1] NA
P <- function(n) rnorm(n) m <- sensitivitySampler(m, oracle = P, n = 100, gamma = 0.33)
#> Sampling sensitivity with m=20 gamma=0.33 k=20
m@sensitivity ## small like 0.03...
#> [1] 0.03416313
m@gammaSensitivity ## 0.33 as directed, now m is (eps,gam)-DP.
#> [1] 0.33