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
15
16
# type: ignore
def sample_geometric_exp_fast(x) -> int:
    if x == 0:
        return 0
    
    s, t = Rational.into_numer_denom(x)
    
    while True:
        u = Integer.sample_uniform_int_below(t) # |\label{line:U}|
        d = bool.sample_bernoulli_exp(Rational(u, t)) # |\label{line:D}|
        if d:
            break
        
    v = sample_geometric_exp_slow(1) # |\label{line:V}|
    z = u + t * v
    return z // s