# Negative Mutual information python

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.

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?

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 ])