@@ -97,18 +97,14 @@ def tau(self, value: Optional[float]) -> None:
97
97
raise TypeError ("tau must be a float or None" )
98
98
self ._tau = value
99
99
100
- def on_fit_end (self , ** kwargs ) -> None :
101
- """On fit end method."""
102
- self .incremental_mean .num_values = len (kwargs ["X" ])
103
-
104
100
def on_update_end (self , value : Union [int , float ], ** kwargs ) -> None :
105
101
"""On update end method.
106
102
107
103
:param value: value to update detector
108
104
:type value: int
109
105
"""
110
106
self .incremental_mean .update (value = value )
111
- self .p_value , likelihood = self ._calculate_p_value (value = value )
107
+ self .p_value , likelihood = self ._calculate_p_value ()
112
108
113
109
self .logs .update (
114
110
{
@@ -134,14 +130,13 @@ def _calculate_tau_squared(
134
130
tau_squared = sigma_squared * minus_b_cdf / (1 / b * norm .pdf (b ) - minus_b_cdf )
135
131
return tau_squared
136
132
137
- def _calculate_p_value (self , value : float ) -> Tuple [float , float ]:
133
+ def _calculate_p_value (self ) -> Tuple [float , float ]:
138
134
likelihood = self ._likelihood_normal_mixing_distribution (
139
135
mean = self .incremental_mean .get (),
140
136
sigma = self .sigma ,
141
137
sigma_squared = self .sigma_squared ,
142
138
tau_squared = self .tau_squared ,
143
139
two_sigma_squared = self .two_sigma_squared ,
144
- value = value ,
145
140
n = self .detector .num_instances , # type: ignore
146
141
)
147
142
p_value = min (
@@ -157,15 +152,14 @@ def _likelihood_normal_mixing_distribution(
157
152
sigma_squared : float ,
158
153
tau_squared : float ,
159
154
two_sigma_squared : float ,
160
- value : float ,
161
155
n : int ,
162
156
) -> float :
163
157
n_tau_squared = n * tau_squared
164
158
sigma_squared_plus_n_tau_squared = sigma_squared + n_tau_squared
165
159
likelihood = (sigma / np .sqrt (sigma_squared_plus_n_tau_squared )) * np .exp (
166
160
n
167
161
* n_tau_squared
168
- * (mean - value ) ** 2
169
- / (two_sigma_squared * ( sigma_squared_plus_n_tau_squared ) )
162
+ * mean ** 2 # (mean - theta ) ** 2, theta = 0 (H_0 value, no distance)
163
+ / (two_sigma_squared * sigma_squared_plus_n_tau_squared )
170
164
)
171
165
return likelihood
0 commit comments