From 32d61d53e0fc40980c7e24cb836e60cf9dfba33f Mon Sep 17 00:00:00 2001 From: Megan Fantes Date: Fri, 7 Jun 2019 14:12:57 -0400 Subject: [PATCH] Change the return statement of bootstrap.replication to return the mean of the partition means (instead of the sum) --- R/mechanism-bootstrap.R | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/R/mechanism-bootstrap.R b/R/mechanism-bootstrap.R index ed8cf58..7bff952 100644 --- a/R/mechanism-bootstrap.R +++ b/R/mechanism-bootstrap.R @@ -34,7 +34,10 @@ bootstrap.replication <- function(x, n, sensitivity, epsilon, fun, inputObject, stat.partitions[[i]] <- currentPartition * stat.currentPartition + noise.currentPartition } stat.out <- do.call(rbind, stat.partitions) - return(apply(stat.out, 2, sum)) + # return(apply(stat.out, 2, sum)) + # returnedBootstrappedResult = apply(stat.out, 2, sum) + returnedBootstrappedResult = apply(X = stat.out, MARGIN = 2, FUN = fun) + return(returnedBootstrappedResult) } # 2: treat it as a partition with a mean of 0 and keep it in the calculation, adding noise and adding it to the final calculation @@ -52,7 +55,7 @@ bootstrap.replication <- function(x, n, sensitivity, epsilon, fun, inputObject, # for (i in 1:max.appearances) { # variance.i <- (i * probs[i] * (sensitivity^2)) / (2 * epsilon) # if (i %in% validPartitions) { -# stat.i <- fun(x[partition == i]) +# stat.i <- inputObject$bootStatEval(x[partition == currentPartition], fun, ...) # noise.i <- dpNoise(n=length(stat.i), scale=sqrt(variance.i), dist='gaussian') # stat.partitions[[i]] <- i * stat.i + noise.i # } else {