File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import numpy as np
22import pytest
33import pydp .algorithms .numerical_mechanisms as num_mech
4- from scipy .special import erfinv
54
65
76REL_ERR_TOL = 1e-5
@@ -71,13 +70,14 @@ def test_gaussian_mechanism():
7170 value = gaussian .add_noise (value )
7271 assert type (value ) is float
7372 conf_level = 0.5
73+ erf_inv_conf_level = 0.4769362762044699 # =erfinv(0.5)
7474 priv_budg = 0.1
7575 interval = gaussian .noise_confidence_interval (0.5 , value )
7676 local_gaussian = num_mech .GaussianMechanism (
7777 priv_budg * epsilon , priv_budg * delta , l2_sensitivity
7878 )
7979 assert type (interval ) is num_mech .ConfidenceInterval
80- bound = erfinv ( - conf_level ) * local_gaussian .std * (2 ** 0.5 )
80+ bound = - erf_inv_conf_level * local_gaussian .std * (2 ** 0.5 )
8181 lower_bound , upper_bound = value - bound , value + bound
8282 assert_almost_eq (lower_bound , interval .lower_bound )
8383 assert_almost_eq (upper_bound , interval .upper_bound )
You can’t perform that action at this time.
0 commit comments