API

LocalInformation — Module
LocalInformation

Local (per-sample, pointwise) information measures, as a companion to Associations.jl.

For an estimator est of an Associations.jl measure, local_association(est, x...) returns one value per sample, and mean(local_association(est, x...)) ≈ association(est, x...). local_entropy does the same for single-variable Shannon entropy estimators.

source
LocalInformation.local_association — Function
local_association(est, x...; backend = CPU(), precision = nothing) → Vector

Return the local (per-sample, pointwise) values of the measure est.definition, estimated with the Associations.jl estimator est from the inputs x..., in sample order and in the unit given by est.definition.base (bits for the default base 2).

Each input is an AbstractVector (one variable) or a StateSpaceSet (a multivariate variable). For every supported estimator,

mean(local_association(est, x...)) ≈ association(est, x...)

up to floating-point rounding (and up to the precision used on a GPU). The decompositions (PID and ΦID) return a result object of per-sample atoms instead of a Vector; for them the identity holds for every atom a: mean(atom(local_association(est, x...), a)) ≈ atom(association(est, x...), a).

Supported estimators

EstimatorDefinitionsGPU
JointProbabilities(def, CodifyVariables(o))MIShannon, CMIShannon, higher-orderno (computed on the CPU)
EntropyDecomposition(def, PlugIn(Shannon()), d)MIShannon, CMIShannon, higher-orderno (computed on the CPU)
EntropyDecomposition(def, Kraskov(...)), EntropyDecomposition(def, KozachenkoLeonenko(...))MIShannon, CMIShannon, higher-orderyes
KSG1, KSG2 (KraskovStögbauerGrassberger1/2)MIShannonyes
FPVPCMIShannonyes
GaussianDecomposition(def; copula)higher-orderyes
GaussianMI, GaussianCMIMIShannon, CMIShannonyes
JointProbabilities(def, CodifyVariables(o))PID: PartialInformationDecomposition(r) with r = ISx() or IPM(), a LocalPIDResult (a Vector for a PIDAtom)counting on the CPU, Möbius inversion on backend
JointProbabilities(def, CodifyVariables(o))ΦID: IntegratedInformationDecomposition(r) with r = IMMI(), ISx() or IPM(), a LocalPhiIDResultcounting on the CPU, Möbius inversion on backend
EntropyDecomposition(def, PlugIn(Shannon()), d)ΦID with IMMI()counting on the CPU, Möbius inversion on backend
EntropyDecomposition(def, Kraskov(...)), EntropyDecomposition(def, KozachenkoLeonenko(...)), GaussianDecomposition(def; copula)ΦID with IMMI()yes

"Higher-order" means TotalCorrelation, DualTotalCorrelation, OInformation and SInformation. Other estimators throw an ArgumentError. Bias-corrected entropy estimators (MillerMadow, ChaoShen, Jackknife, Schuermann, ...) are not supported, because their estimates are not means of per-sample terms. The PID and ΦID methods are documented below. Per-sample ΦID atoms with IMMI() follow the convention of phyid: each local double redundancy is the local mutual information of the pair of variable sets with the smallest mean.

Keywords

  • backend: a KernelAbstractions.jl backend, CPU() (default) or a GPU backend such as CUDABackend() (requires using CUDA). Discrete (counting) estimators always compute on the CPU, whatever the backend: hash-based counting gains nothing on a GPU.
  • precision: the floating-point type to compute in and of the result. nothing (default) means Float64 on the CPU and Float32 on a GPU; precision = Float64 is allowed on a GPU.

The PID and ΦID methods also take memory_limit (bytes, default 2^31), and the PID method takes atoms.

Discretized inputs

With an outcome space that embeds the data (e.g. OrdinalPatterns), there is one local value per encoded symbol, i.e. per embedding vector, not per raw sample.

source
LocalInformation.local_entropy — Function
local_entropy(est::DifferentialInfoEstimator, x; backend = CPU(), precision = nothing) → Vector
local_entropy(est::PlugIn, o::OutcomeSpace, x; backend = CPU(), precision = nothing) → Vector
local_entropy(o::OutcomeSpace, x; kwargs...) → Vector

Local (per-sample) Shannon entropies $h_i = -\log \hat p(x_i)$ of the single variable x (an AbstractVector or a StateSpaceSet), in the unit est.definition.base, with

mean(local_entropy(est, x)) ≈ information(est, x)          # differential
mean(local_entropy(est, o, x)) ≈ information(est, o, x)    # discrete

Supported estimators (from ComplexityMeasures.jl):

  • Kraskov(Shannon(); k, w): $h_i = -\psi(k) + \psi(N) + \log V_D + D \log \rho_i$, with $\rho_i$ the Euclidean distance to the k-th nearest neighbour outside the Theiler window w, and $V_D$ the volume of the Euclidean unit ball.
  • KozachenkoLeonenko(Shannon(); w): $h_i = D \log \rho_i + \log V_D + \gamma + \log(N - 1)$, with $\rho_i$ the distance to the nearest neighbour.
  • PlugIn(Shannon()) with a counting-based outcome space o: $h_i = -\log(n(\omega_i) / N)$, where $\omega_i$ is the outcome of the i-th encoded symbol, $n(\omega)$ its count and $N$ the number of symbols. local_entropy(o, x) uses PlugIn(Shannon()) (base 2). This needs probabilities(o, x) to be the relative counts of the outcomes that codify(o, x) returns. It throws an ArgumentError otherwise: for outcome spaces that are not counting-based (WeightedOrdinalPatterns, AmplitudeAwareOrdinalPatterns, PowerSpectrum, …) and for Dispersion, whose codify gives per-sample symbols while its probabilities count dispersion patterns.

backend and precision are as for local_association. The k-NN estimators run on the CPU (k-d tree) or on a GPU (exact brute-force kernel); the discrete estimator always computes on the CPU.

source