BoundedVariance
computes the variance of values in a dataset, in a differentially private manner.
BoundedVariance
supports int64
s and double
s as inputs. When successful, the returned Output
message will contain one element with the differentially private variance. When bounds are inferred, the Output
additionally contains a BoundingReport
. The returned value is guaranteed to be non-negative, with a maximum possible value of the maximum variance (length of the bounded interval squared divided by four).
BoundedVariance
is a bounded algorithm. There are no additional parameters. Information on how to construct a BoundedVariance
is found in the bounded algorithm documentation. Below is a minimal construction example.
absl::StatusOr<std::unique_ptr<BoundedVariance<int64>>> bounded_var = BoundedVariance<int64>::Builder.SetEpsilon(1) .SetLower(-10) .SetUpper(10) .Build();
BoundedVariance
is an Algorithm
and supports its full API.
For BoundedVariance
, calling Result
is an O(n) operation and requires O(1) additional memory.