Skip to content

Allow conditional independence tests to handle zero variance inputs - #449

Open
ChickenisLegit wants to merge 4 commits into
neurodata:mainfrom
ChickenisLegit:fix-zero-variance-conditional
Open

Allow conditional independence tests to handle zero variance inputs#449
ChickenisLegit wants to merge 4 commits into
neurodata:mainfrom
ChickenisLegit:fix-zero-variance-conditional

Conversation

@ChickenisLegit

Copy link
Copy Markdown
Contributor

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.

…nd return stat 0 and p-value 1 instead of raising ValueError
@netlify

netlify Bot commented Aug 22, 2026

Copy link
Copy Markdown

Deploy Preview for hyppo ready!

Name Link
🔨 Latest commit 2be2b50
🔍 Latest deploy log https://app.netlify.com/projects/hyppo/deploys/6a8c71d52b815f0008f9972c
😎 Deploy Preview https://deploy-preview-449--hyppo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

"""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):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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?

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.

Error when running Conditional DCorr

2 participants