Skip to content

Conversation

@kdund
Copy link
Contributor

@kdund kdund commented Dec 12, 2023

This PR implements a generalised GOF where you need to provide a toyMC generator and distance measure given your model, which then runs toyMCs, computes the distance measure for each and returns the p-value based on that.
In particular, it also provides a circular max-slice GOF evaluators to compute how asymmetrical a theta-distribution is.

@kdund
Copy link
Contributor Author

kdund commented Dec 12, 2023

As an example,
m = FractionInSlice(np.array([0.,0.]),opening_angle = np.pi) m.get_pvalue() returns 0.5 within toyMC precision

@kdund kdund requested review from FaroutYLq and hammannr December 13, 2023 18:22
Copy link
Collaborator

@hammannr hammannr left a comment

Choose a reason for hiding this comment

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

Thanks a lot @kdund for adding this, looks good! A few minor comments but then I think this is good to go! 🚀

self.distance_measure = distance_measure

def get_pvalue(self, n_toys=10000, generator_kwargs={}, distance_measure_kwargs={}):
self.gof = self.distance_measure(self.data, **distance_measure_kwargs)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would suggest defining a trivial method get_gof to get the test statistic value so that it has the same interface as the other tests in this package.

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh. so this is the reason why people call the test statistic gof.

return np.abs((t0 - t1 + np.pi) % (2 * np.pi) - np.pi)

@staticmethod
def get_best_partition(data_t, opening_angle=np.pi, test_angles=None, return_best_angle=False):
Copy link
Collaborator

Choose a reason for hiding this comment

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

please add a short description of all parameters (with types) to the docstring :)

an equal or greater portion in a slice set in the generator
angles in radians
"""
def __init__(self, data, opening_angle=np.pi, fixed_length=True):
Copy link
Collaborator

Choose a reason for hiding this comment

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

opening_angle is not used in the init and fixed_length should be briefly explained in the docstring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants