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

Zeros Vector Breaks Execution #25

Open
Sinansi opened this issue Dec 11, 2019 · 1 comment
Open

Zeros Vector Breaks Execution #25

Sinansi opened this issue Dec 11, 2019 · 1 comment

Comments

@Sinansi
Copy link

Sinansi commented Dec 11, 2019

Hello,

I am running an application that loops over InformationMeasures.get_mutual_information.
If you pass a vector with all elements containing zero (example, Base.zeros()) to this function, the execution of the loop breaks and an error is displayed on the screen.

I suggest if a zeros vector is passed to this function, it just returns a mutual information of 0.0 instead of interrupting the execution of the loop/application.

Thank you!

@KalelR
Copy link

KalelR commented May 5, 2020

This actually happens whenever a vector contains equal elements: could be zeros, ones, or tens, for example.
For a vector named vec, you can check if all elements are equal by using the following function:
allequal(vec) = all(y->y==vec[1],vec)

This is taken from https://stackoverflow.com/questions/47564825/check-if-all-the-elements-of-a-julia-array-are-equal/47578613.

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

2 participants