-
Notifications
You must be signed in to change notification settings - Fork 0
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
Binomial uncertainty #171
Binomial uncertainty #171
Conversation
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.
This test case should work:
In [7]: star_probs.binomial_confidence_interval(1, [1, 2])
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
Cell In[7], line 1
----> 1 star_probs.binomial_confidence_interval(1, [1, 2])
File ~/git/chandra_aca/chandra_aca/star_probs.py:1161, in binomial_confidence_interval(n_true, n_trials, coverage)
1159 n_trials = np.ma.MaskedArray(n_trials, mask=(n_trials == 0))
1160 ratio = np.ones_like(n_true) * np.nan
-> 1161 ratio[~n_trials.mask] = n_true[~n_trials.mask] / n_trials[~n_trials.mask]
1163 # try:
1164 # float(coverage)
1165 # except ValueError:
1166 # raise Exception("The coverage must be a float!") from None
1168 alpha = (1 - coverage) / 2
IndexError: boolean index did not match indexed array along dimension 0; dimension is 1 but corresponding boolean dimension is 2
In [8]: np.broadcast_arrays(1, [1, 2])
Out[8]: [array([1, 1]), array([1, 2])]
In [9]: np.broadcast_arrays(1, 1)
Out[9]: [array(1), array(1)]
@taldcroft I think I addressed all your comments. |
@javierggt - thanks, looking much better. Just one more nitpick, returning a scalar array is technically OK but just not nice.
If you look at acq_success_prob there is a decent idiom for dealing with this. The |
chandra_aca/star_probs.py
Outdated
|
||
|
||
def binomial_confidence_interval(n_true, n_trials, coverage=0.682689): | ||
"""Binomial error calculation using the Jeffreys prior. |
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.
"""Binomial error calculation using the Jeffreys prior. | |
"""Binomial confidence interval calculation using the Jeffreys prior. |
|
||
Parameters | ||
---------- | ||
n_success : numpy array |
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.
The first two can both be int
.
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.
Looks good thanks!
Description
Add binomial uncertainty interval to
star_probs.py
Interface impacts
Testing
Unit tests
Independent check of unit tests by [REVIEWER NAME]
Functional tests
This notebook: coverage.ipynb