Skip to content

Commit

Permalink
Rename MesnerShalisi to MesnerShalizi (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
kahaaga authored Apr 5, 2023
1 parent 5237dac commit 133feaa
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "CausalityTools"
uuid = "5520caf5-2dd7-5c5d-bfcb-a00e56ac49f7"
authors = ["Kristian Agasøster Haaga <kahaaga@gmail.com>", "Tor Einar Møller <temolle@gmail.com>", "George Datseris <datseris.george@gmail.com>"]
repo = "https://github.com/kahaaga/CausalityTools.jl.git"
version = "2.3.0"
version = "2.3.1"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Expand Down
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 2.3.1

- The `MesnerShalisi` estimator is now deprecated and renamed to `MesnerShalizi` (with
correct spelling).

## 2.3.0

- Significant speed-ups for `OCE` by sorting on maximal measure, thus avoiding
Expand Down
4 changes: 2 additions & 2 deletions docs/src/api/api_condmutualinfo.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ GaussianCMI
FPVP
```

### [`MesnerShalisi`](@ref)
### [`MesnerShalizi`](@ref)

```@docs
MesnerShalisi
MesnerShalizi
```

### [`PoczosSchneiderCMI`](@ref)
Expand Down
4 changes: 2 additions & 2 deletions docs/src/examples/examples_conditional_mutual_information.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ z = (z ./ std(z)) .+ y
condmutualinfo(FPVP(k = 5), x, z, y) # defaults to `CMIShannon()`
```

#### [`CMIShannon`](@ref) with [`MesnerShalisi`](@ref)
#### [`CMIShannon`](@ref) with [`MesnerShalizi`](@ref)

```@example mi_demonstration
using CausalityTools
Expand All @@ -59,7 +59,7 @@ z = (z ./ std(z)) .+ y
# We expect zero (in practice: very low) CMI when computing I(X; Z | Y), because
# the link between X and Z is exclusively through Y, so when observing Y,
# X and Z should appear independent.
condmutualinfo(MesnerShalisi(k = 10), x, z, y) # defaults to `CMIShannon()`
condmutualinfo(MesnerShalizi(k = 10), x, z, y) # defaults to `CMIShannon()`
```

#### [`CMIShannon`](@ref) with [`Rahimzamani`](@ref)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/examples_graphs.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ x, y, z, w = columns(trajectory(sys, 400, Ttr = 10000))
# Independence tests for unconditional and conditional stages.
utest = SurrogateTest(MIShannon(), KSG2(k = 3, w = 1); rng, nshuffles = 150)
ctest = LocalPermutationTest(CMIShannon(), MesnerShalisi(k = 3, w = 1); rng, nshuffles = 150)
ctest = LocalPermutationTest(CMIShannon(), MesnerShalizi(k = 3, w = 1); rng, nshuffles = 150)
# Infer graph
alg = OCE(; utest, ctest, α = 0.05, τmax = 1)
Expand Down
13 changes: 3 additions & 10 deletions src/CausalityTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,12 @@ module CausalityTools
# Update messages:
using Scratch
display_update = true
version_number = "2.3.0"
version_number = "2.3.1"
update_name = "update_v$(version_number)"
update_message = """
\nUpdate message: CausalityTools v$(version_number)\n
- Significant speed-ups for `OCE` by sorting on maximal measure, thus avoiding
unnecessary significance tests.
- Default parameters for `OCE` default lag parameter have changed. Now, `τmax = 1`, since
that is the only case considered in the original paper. We also use the
`MesnerShalisi` CMI estimator for the conditional step, because in contrast to
the `FPVP` estimator, it has been shown to be consistent.
- Source code for `OCE` has been drastically simplified by merging the pairwise
and conditional parent finding steps.
- `OCE` result can now be converted to a `SimpleDiGraph` from Graphs.jl.
- The `MesnerShalisi` estimator is now deprecated and renamed to `MesnerShalizi` (with
correct spelling).
"""

if display_update
Expand Down
4 changes: 2 additions & 2 deletions src/causal_graphs/oce/OCE.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export OCE
"""
OCE <: GraphAlgorithm
OCE(; utest::IndependenceTest = SurrogateTest(MIShannon(), KSG2(k = 3, w = 3)),
ctest::C = LocalPermutationTest(CMIShannon(), MesnerShalisi(k = 3, w = 3)),
ctest::C = LocalPermutationTest(CMIShannon(), MesnerShalizi(k = 3, w = 3)),
τmax::T = 1, α = 0.05)
The optimal causation entropy (OCE) algorithm for causal discovery (Sun et al.,
Expand Down Expand Up @@ -44,7 +44,7 @@ from Graphs.jl (see [example](@ref oce_example)).
"""
Base.@kwdef struct OCE{U, C, T} <: GraphAlgorithm
utest::U = SurrogateTest(MIShannon(), KSG2(k = 3, w = 3), nshuffles = 100)
ctest::C = LocalPermutationTest(CMIShannon(), MesnerShalisi(k = 3, w = 3), nshuffles = 100)
ctest::C = LocalPermutationTest(CMIShannon(), MesnerShalizi(k = 3, w = 3), nshuffles = 100)
τmax::T = 1
α = 0.05
end
Expand Down
4 changes: 2 additions & 2 deletions src/methods/infomeasures/condmutualinfo/condmutualinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The supertype of all conditional mutual information estimators.
- [`FPVP`](@ref).
- [`PoczosSchneiderCMI`](@ref).
- [`Rahimzamani`](@ref).
- [`MesnerShalisi`](@ref).
- [`MesnerShalizi`](@ref).
"""
abstract type ConditionalMutualInformationEstimator end
const CMIEstimator = ConditionalMutualInformationEstimator
Expand Down Expand Up @@ -62,7 +62,7 @@ mixed.
| Estimator | Principle | [`CMIShannon`](@ref) | [`CMIRenyiPoczos`](@ref) |
| ---------------------------- | ----------------- | :------------------: | :----------------------: |
| [`FPVP`](@ref) | Nearest neighbors | ✓ | x |
| [`MesnerShalisi`](@ref) | Nearest neighbors | ✓ | x |
| [`MesnerShalizi`](@ref) | Nearest neighbors | ✓ | x |
| [`Rahimzamani`](@ref) | Nearest neighbors | ✓ | x |
| [`PoczosSchneiderCMI`](@ref) | Nearest neighbors | x | ✓ |
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
export MesnerShalizi
export MesnerShalisi

"""
MesnerShalisi <: ConditionalMutualInformationEstimator
MesnerShalisi(k = 1, w = 0)
MesnerShalizi <: ConditionalMutualInformationEstimator
MesnerShalizi(k = 1, w = 0)
The `MesnerShalisi` estimator is an estimator for conditional mutual information for data
The `MesnerShalizi` estimator is an estimator for conditional mutual information for data
that can be mixtures of discrete and continuous data (Mesner & Shalisi et al.,
2020)[^MesnerShalisi2020].
2020)[^MesnerShalizi2020].
[^MesnerShalisi2020]:
[^MesnerShalizi2020]:
Mesner, O. C., & Shalizi, C. R. (2020). Conditional mutual information estimation for
mixed, discrete and continuous data. IEEE Transactions on Information Theory, 67(1),
464-484.
"""
Base.@kwdef struct MesnerShalisi{M} <: ConditionalMutualInformationEstimator
Base.@kwdef struct MesnerShalizi{M} <: ConditionalMutualInformationEstimator
k::Int = 1
w::Int = 0
metric::M = Chebyshev()
end

function estimate(measure::CMIShannon, est::MesnerShalisi, x, y, z)
function MesnerShalisi(args...; kwargs...)
Base.depwarn(
"The `MesnerShalisi` estimator is deprecated due to a type. " *
"Please use `MesnerShalizi` instead`.",
:MesnerShalisi,
)
return MesnerShalizi(args...; kwargs...)
end

function estimate(measure::CMIShannon, est::MesnerShalizi, x, y, z)
e = measure.e
(; k, w, metric) = est
X = StateSpaceSet(x)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include("FPVP.jl")
include("Rahimzamani.jl")
include("PoczosSchneiderCMI.jl")
include("MesnerShalisi.jl")
include("MesnerShalizi.jl")
include("GaussianCMI.jl")

# Definition is actually never used, but we need to define it, so that calling `estimate`
Expand Down
2 changes: 1 addition & 1 deletion src/methods/infomeasures/predictive_asymmetry/PA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ of the other dedicated conditional mutual information estimators.
| [`GaoKannanOhViswanath`](@ref) | [`MutualInformationEstimator`](@ref) | Mixed | ✓ | ✓ |
| [`GaoOhViswanath`](@ref) | [`MutualInformationEstimator`](@ref) | Continuous | ✓ | ✓ |
| [`FPVP`](@ref) | [`ConditionalMutualInformationEstimator`](@ref) | Nearest neighbors | ✓ | ✓ |
| [`MesnerShalisi`](@ref) | [`ConditionalMutualInformationEstimator`](@ref) | Nearest neighbors | ✓ | ✓ |
| [`MesnerShalizi`](@ref) | [`ConditionalMutualInformationEstimator`](@ref) | Nearest neighbors | ✓ | ✓ |
| [`Rahimzamani`](@ref) | [`ConditionalMutualInformationEstimator`](@ref) | Nearest neighbors | ✓ | ✓ |
## Examples
Expand Down
2 changes: 1 addition & 1 deletion src/methods/infomeasures/transferentropy/TEShannon.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ which all boil down to computing conditional mutual information, except for
| [`GaoKannanOhViswanath`](@ref) | [`MutualInformationEstimator`](@ref) | Mixed | ✓ |
| [`GaoOhViswanath`](@ref) | [`MutualInformationEstimator`](@ref) | Continuous | ✓ |
| [`FPVP`](@ref) | [`ConditionalMutualInformationEstimator`](@ref) | Nearest neighbors | ✓ |
| [`MesnerShalisi`](@ref) | [`ConditionalMutualInformationEstimator`](@ref) | Nearest neighbors | ✓ |
| [`MesnerShalizi`](@ref) | [`ConditionalMutualInformationEstimator`](@ref) | Nearest neighbors | ✓ |
| [`Rahimzamani`](@ref) | [`ConditionalMutualInformationEstimator`](@ref) | Nearest neighbors | ✓ |
| [`Zhu1`](@ref) | [`TransferEntropyEstimator`](@ref) | Nearest neighbors | ✓ |
| [`Lindner`](@ref) | [`TransferEntropyEstimator`](@ref) | Nearest neighbors | ✓ |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ exception - they compute transfer entropy directly.
| [`GaoKannanOhViswanath`](@ref) | [`MutualInformationEstimator`](@ref) | Mixed | ✓ | ✖ |
| [`GaoOhViswanath`](@ref) | [`MutualInformationEstimator`](@ref) | Continuous | ✓ | ✖ |
| [`FPVP`](@ref) | [`ConditionalMutualInformationEstimator`](@ref) | Nearest neighbors | ✓ | ✖ |
| [`MesnerShalisi`](@ref) | [`ConditionalMutualInformationEstimator`](@ref) | Nearest neighbors | ✓ | ✖ |
| [`MesnerShalizi`](@ref) | [`ConditionalMutualInformationEstimator`](@ref) | Nearest neighbors | ✓ | ✖ |
| [`Rahimzamani`](@ref) | [`ConditionalMutualInformationEstimator`](@ref) | Nearest neighbors | ✓ | ✖ |
| [`Zhu1`](@ref) | [`TransferEntropyEstimator`](@ref) | Nearest neighbors | ✓ | ✖ |
| [`Lindner`](@ref) | [`TransferEntropyEstimator`](@ref) | Nearest neighbors | ✓ | ✖ |
Expand Down
4 changes: 2 additions & 2 deletions test/causal_graphs/oce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ rng = StableRNG(123)
sys = system(Logistic4Chain(; rng))
X = columns(trajectory(sys, 60, Ttr = 10000))
utest = SurrogateTest(MIShannon(), KSG1(k = 10, w = 1); rng, nshuffles = 30)
ctest = LocalPermutationTest(CMIShannon(), MesnerShalisi(k = 10, w = 1); rng, nshuffles = 30)
ctest = LocalPermutationTest(CMIShannon(), MesnerShalizi(k = 10, w = 1); rng, nshuffles = 30)
alg = OCE(; utest, ctest, τmax = 2)
parents = infer_graph(alg, X; verbose = true)
@test parents isa Vector{<:OCESelectedParents}
Expand All @@ -18,7 +18,7 @@ rng = StableRNG(123)
sys = system(Logistic2Bidir(; rng))
X = columns(trajectory(sys, 300, Ttr = 10000))
utest = SurrogateTest(MIShannon(), KSG1(k = 10, w = 1); rng, nshuffles = 100)
ctest = LocalPermutationTest(CMIShannon(), MesnerShalisi(k = 10, w = 1); rng, nshuffles = 100)
ctest = LocalPermutationTest(CMIShannon(), MesnerShalizi(k = 10, w = 1); rng, nshuffles = 100)
parents = infer_graph(OCE(; utest, ctest, τmax = 1), X; verbose = true)
@test parents isa Vector{<:OCESelectedParents}
g = SimpleDiGraph(parents)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ y = StateSpaceSet(rand(1000, 1))
z = StateSpaceSet(rand(1000, 1))

@test FPVP() isa FPVP
@test MesnerShalisi() isa MesnerShalisi
@test MesnerShalisi() isa MesnerShalizi
@test MesnerShalizi() isa MesnerShalizi
@test PoczosSchneiderCMI() isa PoczosSchneiderCMI
@test Rahimzamani() isa Rahimzamani
@test GaussianCMI() isa GaussianCMI
@test condmutualinfo(FPVP(), x, y, z) isa Real
@test condmutualinfo(MesnerShalisi(), x, y, z) isa Real
@test condmutualinfo(MesnerShalizi(), x, y, z) isa Real
@test condmutualinfo(PoczosSchneiderCMI(), x, y, z) isa Real
@test condmutualinfo(Rahimzamani(), x, y, z) isa Real
@test condmutualinfo(GaussianCMI(), x, y, z) isa Real
Expand Down

0 comments on commit 133feaa

Please sign in to comment.