Source code for dit.pid.measures.irav

"""
The I_rav measure, defining a 'redundancy' auxiliary variable to capture the
redundant information between sources
"""

from ...distconst import RVFunctions, insert_rvf
from ...multivariate import coinformation
from ...utils import extended_partition, partitions
from ..pid import BasePID

__all__ = ("PID_RAV",)


[docs] class PID_RAV(BasePID): """ The maximum coinformation auxiliary random variable method. """ _name = "I_RAV" @staticmethod def _measure(d, sources, target): """ I_RAV is maximum coinformation between all sources, targets, and an arbitrary function of the sources. Parameters ---------- d : Distribution The distribution to compute i_rav for. sources : iterable of iterables The source variables. target : iterable The target variable. Returns ------- i_rav : float The value of I_RAV. """ d = d.coalesce(sources + (target,)) source_parts = partitions(d.marginal(sum(d.rvs[:-1], [])).outcomes) outcomes = d.outcomes ctor = d._outcome_ctor idxs = list(range(len(sources))) parts = [extended_partition(outcomes, idxs, source_part, ctor) for source_part in source_parts] bf = RVFunctions(d) extended_dists = [insert_rvf(d, bf.from_partition(part)) for part in parts] return max(coinformation(extended_dist) for extended_dist in extended_dists)