1
$\begingroup$

I calculated mutual information with the PyInform function with

local = True

MI = mutual_info(xs, ys, local=True)

In blue you see MI between the yellow and green line. enter image description here

Can anyone tell me why MI goes into the negative? Should I set the negative values to zero or do you think made an error somewhere else?

$\endgroup$

1 Answer 1

1
$\begingroup$

The negative values are correct results.
Due to setting local = True the function is calculating the pointwise mutual information (referred to as local mutual information in the documentation).
The pointwise mutual information can take positive as well as negative values.
You can also see this in the example output given in the documentation you linked to:

>>> xs = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1]
>>> ys = [0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1]
>>> mutual_info(xs, ys)
0.21417094500762912
>>> mutual_info(xs, ys, local=True)
array([-1.        , -1.        ,  0.22239242,  0.22239242,  0.22239242,
        0.22239242,  0.22239242,  0.22239242,  0.22239242,  0.22239242,
        0.22239242,  0.22239242,  0.22239242,  0.22239242,  0.22239242,
        0.22239242,  1.5849625 ,  1.5849625 ,  1.5849625 , -1.5849625 ])
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.