def testRejection2D(self): num_samples = int(1e5) # Chosen for a small min detectable discrepancy det_bounds = np.array( [0.01, 0.02, 0.03, 0.04, 0.05, 0.3, 0.35, 0.4, 0.5], dtype=np.float32) exact_volumes = two_by_two_volume(det_bounds) (rej_weights, rej_proposal_volume ) = corr.correlation_matrix_volume_rejection_samples(det_bounds, 2, [num_samples, 9], dtype=np.float32, seed=43) # shape of rej_weights: [num_samples, 9, 2, 2] chk1 = st.assert_true_mean_equal_by_dkwm(rej_weights, low=0., high=rej_proposal_volume, expected=exact_volumes, false_fail_rate=1e-6) chk2 = tf1.assert_less( st.min_discrepancy_of_true_means_detectable_by_dkwm( num_samples, low=0., high=rej_proposal_volume, # Correct the false fail rate due to different broadcasting false_fail_rate=1.1e-7, false_pass_rate=1e-6), 0.036) with tf.control_dependencies([chk1, chk2]): rej_weights = tf.identity(rej_weights) self.evaluate(rej_weights)
def testRejection4D(self): num_samples = int(1e5) # Chosen for a small min detectable discrepancy det_bounds = np.array([0.0], dtype=np.float32) exact_volumes = [four_by_four_volume()] (rej_weights, rej_proposal_volume ) = corr.correlation_matrix_volume_rejection_samples(det_bounds, 4, [num_samples, 1], dtype=np.float32, seed=45) # shape of rej_weights: [num_samples, 1, 4, 4] chk1 = st.assert_true_mean_equal_by_dkwm(rej_weights, low=0., high=rej_proposal_volume, expected=exact_volumes, false_fail_rate=1e-6) chk2 = tf1.assert_less( st.min_discrepancy_of_true_means_detectable_by_dkwm( num_samples, low=0., high=rej_proposal_volume, false_fail_rate=1e-6, false_pass_rate=1e-6), # Going for about a 10% relative error 1.1) with tf.control_dependencies([chk1, chk2]): rej_weights = tf.identity(rej_weights) self.evaluate(rej_weights)
def testRejection4D(self): num_samples = int(1e5) # Chosen for a small min detectable discrepancy det_bounds = np.array([0.0], dtype=np.float32) exact_volumes = [four_by_four_volume()] (rej_weights, rej_proposal_volume) = corr.correlation_matrix_volume_rejection_samples( det_bounds, 4, [num_samples, 1], dtype=np.float32, seed=45) # shape of rej_weights: [num_samples, 1, 4, 4] chk1 = st.assert_true_mean_equal_by_dkwm( rej_weights, low=0., high=rej_proposal_volume, expected=exact_volumes, false_fail_rate=1e-6) chk2 = tf.assert_less( st.min_discrepancy_of_true_means_detectable_by_dkwm( num_samples, low=0., high=rej_proposal_volume, false_fail_rate=1e-6, false_pass_rate=1e-6), # Going for about a 10% relative error 1.1) with tf.control_dependencies([chk1, chk2]): rej_weights = tf.identity(rej_weights) self.evaluate(rej_weights)
def testRejection2D(self): num_samples = int(1e5) # Chosen for a small min detectable discrepancy det_bounds = np.array( [0.01, 0.02, 0.03, 0.04, 0.05, 0.3, 0.35, 0.4, 0.5], dtype=np.float32) exact_volumes = two_by_two_volume(det_bounds) (rej_weights, rej_proposal_volume) = corr.correlation_matrix_volume_rejection_samples( det_bounds, 2, [num_samples, 9], dtype=np.float32, seed=43) # shape of rej_weights: [num_samples, 9, 2, 2] chk1 = st.assert_true_mean_equal_by_dkwm( rej_weights, low=0., high=rej_proposal_volume, expected=exact_volumes, false_fail_rate=1e-6) chk2 = tf.assert_less( st.min_discrepancy_of_true_means_detectable_by_dkwm( num_samples, low=0., high=rej_proposal_volume, # Correct the false fail rate due to different broadcasting false_fail_rate=1.1e-7, false_pass_rate=1e-6), 0.036) with tf.control_dependencies([chk1, chk2]): rej_weights = tf.identity(rej_weights) self.evaluate(rej_weights)