API
LocalInformation — Module
LocalInformationLocal (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.
LocalInformation.local_association — Function
local_association(est, x...; backend = CPU(), precision = nothing) → VectorReturn 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
| Estimator | Definitions | GPU |
|---|---|---|
JointProbabilities(def, CodifyVariables(o)) | MIShannon, CMIShannon, higher-order | no (computed on the CPU) |
EntropyDecomposition(def, PlugIn(Shannon()), d) | MIShannon, CMIShannon, higher-order | no (computed on the CPU) |
EntropyDecomposition(def, Kraskov(...)), EntropyDecomposition(def, KozachenkoLeonenko(...)) | MIShannon, CMIShannon, higher-order | yes |
KSG1, KSG2 (KraskovStögbauerGrassberger1/2) | MIShannon | yes |
FPVP | CMIShannon | yes |
GaussianDecomposition(def; copula) | higher-order | yes |
GaussianMI, GaussianCMI | MIShannon, CMIShannon | yes |
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 LocalPhiIDResult | counting 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 asCUDABackend()(requiresusing 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) meansFloat64on the CPU andFloat32on a GPU;precision = Float64is 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.
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...) → VectorLocal (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) # discreteSupported 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 thek-th nearest neighbour outside the Theiler windoww, 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 spaceo: $h_i = -\log(n(\omega_i) / N)$, where $\omega_i$ is the outcome of thei-th encoded symbol, $n(\omega)$ its count and $N$ the number of symbols.local_entropy(o, x)usesPlugIn(Shannon())(base 2). This needsprobabilities(o, x)to be the relative counts of the outcomes thatcodify(o, x)returns. It throws anArgumentErrorotherwise: for outcome spaces that are not counting-based (WeightedOrdinalPatterns,AmplitudeAwareOrdinalPatterns,PowerSpectrum, …) and forDispersion, whosecodifygives 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.