1- #!/usr/bin/env python3
2- # -*- coding: utf-8 -*-
3-
41import numpy
52import scipy .stats
63import scipy .spatial
118from csep .core .regions import QuadtreeGrid2D
129
1310def _nbd_number_test_ndarray (fore_cnt , obs_cnt , variance , epsilon = 1e-6 ):
14- """
15- Computes delta1 and delta2 values from the Negative Binomial (NBD) number test.
11+ """ Computes delta1 and delta2 values from the Negative Binomial (NBD) number test.
1612
1713 Args:
1814 fore_cnt (float): parameter of negative binomial distribution coming from expected value of the forecast
@@ -36,8 +32,7 @@ def _nbd_number_test_ndarray(fore_cnt, obs_cnt, variance, epsilon=1e-6):
3632
3733
3834def negative_binomial_number_test (gridded_forecast , observed_catalog , variance ):
39- """
40- Computes "negative binomial N-Test" on a gridded forecast.
35+ """ Computes "negative binomial N-Test" on a gridded forecast.
4136
4237 Computes Number (N) test for Observed and Forecasts. Both data sets are expected to be in terms of event counts.
4338 We find the Total number of events in Observed Catalog and Forecasted Catalogs. Which are then employed to compute the
@@ -84,8 +79,7 @@ def negative_binomial_number_test(gridded_forecast, observed_catalog, variance):
8479
8580
8681def binary_joint_log_likelihood_ndarray (forecast , catalog ):
87- """
88- Computes Bernoulli log-likelihood scores, assuming that earthquakes follow a binomial distribution.
82+ """ Computes Bernoulli log-likelihood scores, assuming that earthquakes follow a binomial distribution.
8983
9084 Args:
9185 forecast: Forecast of a Model (Gridded) (Numpy Array)
@@ -112,8 +106,8 @@ def binary_joint_log_likelihood_ndarray(forecast, catalog):
112106
113107def _binary_likelihood_test (forecast_data , observed_data , num_simulations = 1000 , random_numbers = None ,
114108 seed = None , use_observed_counts = True , verbose = True , normalize_likelihood = False ):
115- """
116- Computes binary conditional-likelihood test from CSEP using an efficient simulation based approach.
109+ """ Computes binary conditional-likelihood test from CSEP using an efficient simulation based approach.
110+
117111 Args:
118112 forecast_data (numpy.ndarray): nd array where [:, -1] are the magnitude bins.
119113 observed_data (numpy.ndarray): same format as observation.
@@ -184,17 +178,19 @@ def _binary_likelihood_test(forecast_data, observed_data, num_simulations=1000,
184178
185179
186180def binary_spatial_test (gridded_forecast , observed_catalog , num_simulations = 1000 , seed = None , random_numbers = None , verbose = False ):
187- """
188- Performs the binary spatial test on the Forecast using the Observed Catalogs.
181+ """ Performs the binary spatial test on the Forecast using the Observed Catalogs.
182+
189183 Note: The forecast and the observations should be scaled to the same time period before calling this function. This increases
190184 transparency as no assumptions are being made about the length of the forecasts. This is particularly important for
191185 gridded forecasts that supply their forecasts as rates.
186+
192187 Args:
193188 gridded_forecast: csep.core.forecasts.GriddedForecast
194189 observed_catalog: csep.core.catalogs.Catalog
195190 num_simulations (int): number of simulations used to compute the quantile score
196191 seed (int): used fore reproducibility, and testing
197192 random_numbers (numpy.ndarray): random numbers used to override the random number generation. injection point for testing.
193+
198194 Returns:
199195 evaluation_result: csep.core.evaluations.EvaluationResult
200196 """
@@ -228,8 +224,7 @@ def binary_spatial_test(gridded_forecast, observed_catalog, num_simulations=1000
228224
229225
230226def binary_conditional_likelihood_test (gridded_forecast , observed_catalog , num_simulations = 1000 , seed = None , random_numbers = None , verbose = False ):
231- """
232- Performs the binary conditional likelihood test on Gridded Forecast using an Observed Catalog.
227+ """ Performs the binary conditional likelihood test on Gridded Forecast using an Observed Catalog.
233228
234229 Normalizes the forecast so the forecasted rate are consistent with the observations. This modification
235230 eliminates the strong impact differences in the number distribution have on the forecasted rates.
@@ -277,8 +272,7 @@ def binary_conditional_likelihood_test(gridded_forecast, observed_catalog, num_s
277272
278273
279274def matrix_binary_t_test (target_event_rates1 , target_event_rates2 , n_obs , n_f1 , n_f2 , catalog , alpha = 0.05 ):
280- """
281- Computes binary T test statistic by comparing two target event rate distributions.
275+ """ Computes binary T test statistic by comparing two target event rate distributions.
282276
283277 We compare Forecast from Model 1 and with Forecast of Model 2. Information Gain per Active Bin (IGPA) is computed, which is then
284278 employed to compute T statistic. Confidence interval of Information Gain can be computed using T_critical. For a complete
@@ -336,8 +330,7 @@ def matrix_binary_t_test(target_event_rates1, target_event_rates2, n_obs, n_f1,
336330
337331
338332def binary_paired_t_test (forecast , benchmark_forecast , observed_catalog , alpha = 0.05 , scale = False ):
339- """
340- Computes the binary t-test for gridded earthquake forecasts.
333+ """ Computes the binary t-test for gridded earthquake forecasts.
341334
342335 This score is positively oriented, meaning that positive values of the information gain indicate that the
343336 forecast is performing better than the benchmark forecast.
0 commit comments