Skip to content

Commit 94dee18

Browse files
bayonato89wsavran
andauthored
Non poissonian tests (#205)
* Added non-Poissonian comparative and consistency tests. * Added a _simulate_catalog function for binary likelihood tests Co-authored-by: wsavran <35315438+wsavran@users.noreply.github.com>
1 parent ec78dd0 commit 94dee18

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

csep/core/binomial_evaluations.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,29 @@ def binary_joint_log_likelihood_ndarray(forecast, catalog):
102102
return sum(first_term.data + second_term.data)
103103

104104

105+
def _simulate_catalog(num_events, sampling_weights, sim_fore, random_numbers=None):
106+
107+
# generate uniformly distributed random numbers in [0,1), this
108+
if random_numbers is None:
109+
random_numbers = numpy.random.rand(num_events)
110+
else:
111+
# TODO: ensure that random numbers are all between 0 and 1.
112+
pass
113+
114+
# reset simulation array to zero, but don't reallocate
115+
sim_fore.fill(0)
116+
117+
eqs = 0
118+
while eqs < num_events:
119+
random_num = numpy.random.uniform(0,1)
120+
loc = numpy.searchsorted(sampling_weights, random_num)
121+
if sim_fore[loc] == 0:
122+
numpy.add.at(sim_fore, loc, 1)
123+
eqs = eqs+1
124+
125+
return sim_fore
126+
127+
105128
def _binary_likelihood_test(forecast_data, observed_data, num_simulations=1000, random_numbers=None,
106129
seed=None, use_observed_counts=True, verbose=True, normalize_likelihood=False):
107130
""" Computes binary conditional-likelihood test from CSEP using an efficient simulation based approach.

0 commit comments

Comments
 (0)