Allow conditional independence tests to handle zero variance inputs - #449
Open
ChickenisLegit wants to merge 4 commits into
Open
Allow conditional independence tests to handle zero variance inputs#449ChickenisLegit wants to merge 4 commits into
ChickenisLegit wants to merge 4 commits into
Conversation
…nd return stat 0 and p-value 1 instead of raising ValueError
✅ Deploy Preview for hyppo ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
sampan501
requested changes
Aug 24, 2026
| """Checks inputs for all independence tests""" | ||
|
|
||
| def __init__(self, x, y, z, reps=None, max_dims=None, ignore_z_var=False): | ||
| def __init__(self, x, y, z=None, reps=None, max_dims=None, ignore_z_var=False): |
Collaborator
There was a problem hiding this comment.
Why is z=None here? Z is a necessary input for the conditional test and we should just verify that np.var(z) == 0 right?
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #410. In conditional independence testing, the inputs might have 0 variance, which previously threw a \ValueError: Data variance is 0\ in _CheckInputs. This PR allows zero-variance inputs by skipping the ValueError and explicitly checking for zero variance within the test functions (\CDcorr, \FCIT, \KCI, \PCorr, \PDCorr), returning a statistic of 0.0 and a p-value of 1.0.