-
Notifications
You must be signed in to change notification settings - Fork 24
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
wsavran
merged 9 commits into
SCECcode:v0.6.1-release-branch
from
bayonato89:non_poissonian_tests
Nov 14, 2022
Merged
Non poissonian tests #205
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
51690bc
Changed np for numpy in the poisson_evaluations.py file
bayonato89 d758a15
Merge branch 'SCECcode:master' into master
bayonato89 19c84f3
Merge branch 'SCECcode:master' into master
bayonato89 3f29b45
Added non-Poissonian comparative and consistency tests.
bayonato89 fc28b70
format docstrings
wsavran f36b1df
Rename non_poissonian_evaluations.py to binomial_evaluations.py
wsavran b64e4d9
Update binomial_evaluations.py
wsavran 6e6c93d
Added a _simulate_catalog function for binary likelihood tests
bayonato89 4fce41a
Merge branch 'v0.6.1-release-branch' into non_poissonian_tests
wsavran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
|
||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 calledrandom_num
. i think we still need to keep thesim_fore.fill(0)
should be included.