Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non poissonian tests #205

Merged
23 changes: 23 additions & 0 deletions csep/core/binomial_evaluations.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,29 @@ def binary_joint_log_likelihood_ndarray(forecast, catalog):
return sum(first_term.data + second_term.data)


def _simulate_catalog(num_events, sampling_weights, sim_fore, random_numbers=None):

# generate uniformly distributed random numbers in [0,1), this
if random_numbers is None:
random_numbers = numpy.random.rand(num_events)
else:
# TODO: ensure that random numbers are all between 0 and 1.
pass

# reset simulation array to zero, but don't reallocate
sim_fore.fill(0)
Comment on lines +108 to +115
Copy link
Collaborator

@wsavran wsavran Oct 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bayonato89 @khawajasim can we remove this part of the function? the vector random_numbers is not used for anything it seems. the simulation below allocates a new array called random_num. i think we still need to keep the sim_fore.fill(0) should be included.


eqs = 0
while eqs < num_events:
random_num = numpy.random.uniform(0,1)
loc = numpy.searchsorted(sampling_weights, random_num)
if sim_fore[loc] == 0:
numpy.add.at(sim_fore, loc, 1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be indexed

eqs = eqs+1

return sim_fore


def _binary_likelihood_test(forecast_data, observed_data, num_simulations=1000, random_numbers=None,
seed=None, use_observed_counts=True, verbose=True, normalize_likelihood=False):
""" Computes binary conditional-likelihood test from CSEP using an efficient simulation based approach.
Expand Down