opendp 0.14.2

A library of differential privacy algorithms for the statistical analysis of sensitive private data.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
# type: ignore
def noisy_top_k(
    x: list[TIA],
    scale: RBig,
    k: usize,
    negate: bool,
    replacement: bool,
):
    sign = Sign.from_(negate)
    scale = scale.into_rational()

    y = [x_i.into_rational() * sign for x_i in x]  # `\label{negate}`
    return peel_permute_and_flip(y, scale, k, replacement)