Skip to content

Commit

Permalink
Transfer entropy syntax bug (#338)
Browse files Browse the repository at this point in the history
* Add test

* Changelog and version
  • Loading branch information
kahaaga authored Oct 2, 2023
1 parent 74bb6f8 commit 5909d72
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 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 <[email protected]>", "Tor Einar Møller <[email protected]>", "George Datseris <[email protected]>"]
repo = "https://github.com/kahaaga/CausalityTools.jl.git"
version = "2.9.0"
version = "2.9.1"

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

## 2.9

### Bug fixes

- Fixed bug in `transferentropy` function which yielded identical results in both directions for the bivariate case.

## 2.8.0

Moved to DynamicalSystemsBase v3.0 (`trajectory` now returns both the data and the time
Expand Down
9 changes: 6 additions & 3 deletions src/methods/infomeasures/transferentropy/transferentropy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,15 @@ include("optimization/optimization.jl")
include("TEShannon.jl")
include("TERenyiJizba.jl")

function transferentropy(args...; kwargs...)
return estimate(args...; kwargs...)
function transferentropy(measure::TransferEntropy, est::TE_ESTIMATORS, args...; kwargs...)
return estimate(measure, est, args...; kwargs...)
end
function transferentropy(est::TE_ESTIMATORS, args...; kwargs...)
return estimate(TEShannon(), est, args...; kwargs...)
end

function estimate(est::TE_ESTIMATORS, args...; kwargs...)
estimate(TEShannon(), est, args...; kwargs...)
return estimate(TEShannon(), est, args...; kwargs...)
end

function estimate(measure::TransferEntropy, est::TE_ESTIMATORS, x...)
Expand Down
4 changes: 4 additions & 0 deletions test/methods/infomeasures/transferentropy.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
x, y, z = rand(1000), rand(1000), rand(1000)

# Transfer entropy is asymmetric.
pest = SymbolicPermutation(m = 2)
@test transferentropy(TEShannon(), pest, x, y) != transferentropy(TEShannon(), pest, y, x)

est = Lindner( k = 5)
@test transferentropy(est, x, y) isa Real

Expand Down

2 comments on commit 5909d72

@kahaaga
Copy link
Member Author

@kahaaga kahaaga commented on 5909d72 Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/92633

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v2.9.1 -m "<description of version>" 5909d72192278e5ef383ff37bafbbead85feb4be
git push origin v2.9.1

Please sign in to comment.