Skip to content

Commit

Permalink
fix a few bits of pid stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Autoplectic committed Sep 25, 2017
1 parent 2cde5a2 commit c6fcaa7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
15 changes: 10 additions & 5 deletions dit/pid/iccs.py
Expand Up @@ -67,21 +67,26 @@ def pmi(input_, output):

pmis = {tuple(marg): pmi(marg[0], marg[1]) for marg in marginals[1:]}

inputs_dist = sub_dists[tuple(vars[:-1])]
output_dist = sub_dists[(vars[-1],)]
joint_pmis = {e: np.log2(d[e]/(inputs_dist[e[:-1]]*output_dist[(e[-1],)])) for e in d.outcomes}

coinfos = {e: np.log2(np.prod(
[sub_dists[sub_var][tuple(e[i] for i in flatten(sub_var))] ** ((-1) ** len(sub_var)) for sub_var in sub_vars]))
for e in d.outcomes}

# fix the sign of things close to zero
for pmi in pmis.values():
for e, val in pmi.items():
if np.isclose(val, 0.0):
pmi[e] = 0.0

coinfos = {e: np.log2(np.prod(
[sub_dists[sub_var][tuple(e[i] for i in flatten(sub_var))] ** ((-1) ** len(sub_var)) for sub_var in sub_vars]))
for e in d.outcomes}
for e, val in coinfos.items():
if np.isclose(val, 0.0):
coinfos[e] = 0.0

i = sum(d[e] * coinfos[e] for e in d.outcomes if
all(np.sign(coinfos[e]) == np.sign(pmi[tuple(e[i] for i in marg)]) for marg, pmi in pmis.items()))
all(np.sign(coinfos[e]) == np.sign(pmi[tuple(e[i] for i in marg)]) for marg, pmi in pmis.items()) \
and np.sign(coinfos[e]) == np.sign(joint_pmis[e]))

return i

Expand Down
8 changes: 4 additions & 4 deletions docs/measures/pid.rst
Expand Up @@ -371,10 +371,10 @@ This decomposition also displays an interesting phenomena, that of *subadditive
╚════════╧════════╧════════╝

.. py:module:: dit.pid.idep
:math:`\I_{dep}`
----------------
:math:`\Idep{\bullet}`
----------------------

James et al have developed a method of quantifying unique information based on the :ref:`Dependency Decomposition`. Unique information from variable :math:`X_i` is evaluated as the least change in sources-target mutual information when adding the constraint :math:`X_i Y`.
James et al :cite:`james2017unique` have developed a method of quantifying unique information based on the :ref:`Dependency Decomposition`. Unique information from variable :math:`X_i` is evaluated as the least change in sources-target mutual information when adding the constraint :math:`X_i Y`.

.. ipython::

Expand All @@ -393,7 +393,7 @@ James et al have developed a method of quantifying unique information based on t
:math:`\Ipm{\bullet}`
---------------------

Also taking a pointwise view, Finn & Lizier's :math:`\Ipm{\bullet}` instead splits the pointwise mutual information into two components:
Also taking a pointwise view, Finn & Lizier's :math:`\Ipm{\bullet}` :cite:`finn2017` instead splits the pointwise mutual information into two components:

.. math::
Expand Down
23 changes: 23 additions & 0 deletions docs/references.bib
Expand Up @@ -379,6 +379,13 @@ @incollection{griffith2014quantifying
publisher={Springer}
}

@article{banerjee2017computing,
title={Computing the Unique Information},
author={Banerjee, Pradeep Kr. and Rauh, Johannes and Mont{\'u}far, Guido},
journal={arXive preprint arXiv:1709.07487},
year={2017}
}

% i_wedge
@article{griffith2014intersection,
title={Intersection information based on common randomness},
Expand All @@ -403,6 +410,22 @@ @article{ince2017measuring
publisher={Multidisciplinary Digital Publishing Institute}
}

% i_dep
@article{james2017unique,
title={Unique Information via Dependency Constraints},
author={James, Ryan G. and Emenheiser, Jeffrey and Crutchfield, James P.},
journal={arXiv preprint arXiv:1709.06653},
year={2017}
}

% i_pm
@article{finn2017,
title={},
author={Finn, Conor and Lizier, Joseph},
journal={},
year={2017}
}

%% supporting
@inproceedings{bertschinger2013shared,
Expand Down

0 comments on commit c6fcaa7

Please sign in to comment.