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

Add Error Handling for cit.py line 165/166 #107

Closed
maddiehill opened this issue Apr 3, 2023 · 3 comments
Closed

Add Error Handling for cit.py line 165/166 #107

maddiehill opened this issue Apr 3, 2023 · 3 comments

Comments

@maddiehill
Copy link

Hi, I experienced a ValueError: math domain error on this line from log as the value of (1 + r) / (1 - r) was negative.
Please see the screenshot below and the value of r from the debugger.
I'm not sure why this might be happening, but it would be good to catch potential errors here :)

Screenshot 2023-04-03 at 16 57 04

@kunwuz
Copy link
Collaborator

kunwuz commented Apr 6, 2023

Thanks for reporting. Math errors are a little bit tricky, and sometimes we just don't know why, especially with finite samples :) @chenweiDelight @MarkDana Any thoughts on potential causes? Or shall we first add handling there?

MarkDana added a commit to MarkDana/causal-learn that referenced this issue Apr 7, 2023
See issue py-why#107 for details.

The numerical issue of |sample partial correlation|>=1 happens when the samplesize is very small, or the relationship is deterministic.

Abs set to 1. - machine epsilon.

No tests required.
MarkDana added a commit to MarkDana/causal-learn that referenced this issue Apr 7, 2023
See issue py-why#107 for details.

The numerical issue of |sample partial correlation|>=1 happens when the samplesize is very small, or the relationship is deterministic.

Abs set to 1. - machine epsilon.

No tests required.
MarkDana added a commit to MarkDana/causal-learn that referenced this issue Apr 7, 2023
See issue py-why#107 for details.

The numerical issue of |sample partial correlation|>=1 happens when the samplesize is very small, or the relationship is deterministic.

Abs set to 1. - machine epsilon.

No tests required.

Signed-off-by: Haoyue Dai <hyda@cmu.edu>
MarkDana added a commit to MarkDana/causal-learn that referenced this issue Apr 7, 2023
See issue py-why#107 for details.

The numerical issue of |sample partial correlation|>=1 happens when the samplesize is very small, or the relationship is deterministic.

Abs set to 1. - machine epsilon.

No tests required.

Signed-off-by: Haoyue Dai <hyda@cmu.edu>
@MarkDana
Copy link
Collaborator

MarkDana commented Apr 7, 2023

Hi @maddiehill Thanks so much for identifying this! I just made a pr #108 to solve this. The numerical issue of |sample partial correlation|>=1 happens when the samplesize is very small, or the relationship is deterministic. So we set the abs to 1. - machine epsilon to prevent log(<=0) errors.

Thanks again!

@MarkDana MarkDana closed this as completed Apr 7, 2023
@maddiehill
Copy link
Author

Great @MarkDana @kunwuz thanks for fixing this so fast!

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

No branches or pull requests

3 participants