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

Fix/k stest #167

Merged
merged 9 commits into from
Jul 3, 2024
Merged

Fix/k stest #167

merged 9 commits into from
Jul 3, 2024

Conversation

aronsho
Copy link
Collaborator

@aronsho aronsho commented Jun 21, 2024

The ks test had the problem that it did not take into account bins that were empty, skewing the result.

@aronsho aronsho requested a review from lmizrahi June 21, 2024 15:53
@aronsho
Copy link
Collaborator Author

aronsho commented Jun 21, 2024

@lmizrahi the test fail, but I think this is because they are set up the wrong way. Lets discuss this in a 4eye session?

Copy link
Collaborator Author

@aronsho aronsho left a comment

Choose a reason for hiding this comment

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

Done by Leila

@@ -44,6 +44,8 @@ def cdf_discrete_GR(

def empirical_cdf(
sample: np.ndarray | pd.Series,
mc: float = None,
delta_m: float = 0,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

0 does not make sense, put a warning that binning is in fact needed
Default small (e-16? +warning that can take long)


x, y_count = np.unique(x, return_counts=True)
# add empty bins
if delta_m > 0:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

delta_m is always >0

idx = np.argsort(x)
x = x[idx]
y_count = y_count[idx]

y = y[np.cumsum(y_count) - 1]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

np.cumsum(y_count) can be zero at the beginning.
Then, we want the corresponding y to be 0

@aronsho aronsho linked an issue Jul 3, 2024 that may be closed by this pull request
@aronsho aronsho merged commit ae59690 into main Jul 3, 2024
1 check passed
@aronsho aronsho deleted the fix/KStest branch July 3, 2024 12:33
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.

bug: mc_ks does not return the same result as it used to.
2 participants