opendp 0.14.2-dev.20260401.2

A library of differential privacy algorithms for the statistical analysis of sensitive private data.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# type: ignore
def quantile_cnd(
    uniform: RBig, f: Callable[[RBig], RBig], c: RBig
) -> RBig | None:
    if uniform < c:
        return quantile_cnd(RBig(1) - f(uniform), f, c) - RBig(1)
    elif uniform <= RBig(1) - c:  # the linear function
        num = uniform - RBig(1, 2)
        den = RBig(1) - RBig(2) * c
        if den.is_zero():
            return
        return num / den
    else:
        return quantile_cnd(f(RBig(1) - uniform), f, c) + RBig(1)