Skip to content

Commit

Permalink
Merge pull request #42 from kahaaga/releases/v0.2.0
Browse files Browse the repository at this point in the history
Releases/v0.2.0
  • Loading branch information
kahaaga authored Nov 25, 2018
2 parents 4f0c147 + e02f72e commit 2fbb73a
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 59 deletions.
38 changes: 19 additions & 19 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ version = "0.8.10"

[[BinaryProvider]]
deps = ["Libdl", "Pkg", "SHA", "Test"]
git-tree-sha1 = "9930c1a6cd49d9fcd7218df6be417e6ae4f1468a"
git-tree-sha1 = "055eb2690182ebc31087859c3dd8598371d3ef9e"
uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
version = "0.5.2"
version = "0.5.3"

[[BlackBoxOptim]]
deps = ["CPUTime", "Compat", "Distributed", "Distributions", "LinearAlgebra", "Logging", "Pkg", "Printf", "Random", "SHA", "Serialization", "Statistics", "StatsBase", "Test"]
Expand Down Expand Up @@ -139,9 +139,9 @@ version = "4.7.0"

[[DelayEmbeddings]]
deps = ["Distances", "LinearAlgebra", "NearestNeighbors", "StaticArrays", "StatsBase", "Test"]
git-tree-sha1 = "daa7e6a0e354f47d8fb17eb4fe68099fa86e1896"
git-tree-sha1 = "6d42460dc2c84058850b26da7b5174fb6fcd213e"
uuid = "5732040d-69e3-5649-938a-b6b4f237613f"
version = "0.1.0"
version = "0.1.1"

[[DelimitedFiles]]
deps = ["Mmap"]
Expand Down Expand Up @@ -285,9 +285,9 @@ version = "0.16.4"

[[DocStringExtensions]]
deps = ["LibGit2", "Markdown", "Pkg", "Test"]
git-tree-sha1 = "a016e0bfe98a748c4488e2248c2ef4c67d6fdd35"
git-tree-sha1 = "1df01539a1c952cef21f2d2d1c092c2bcf0177d7"
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
version = "0.5.0"
version = "0.6.0"

[[Documenter]]
deps = ["Base64", "DocStringExtensions", "InteractiveUtils", "LibGit2", "Logging", "Markdown", "Pkg", "REPL", "Random", "Test", "Unicode"]
Expand Down Expand Up @@ -390,9 +390,9 @@ version = "0.1.1"

[[JSON]]
deps = ["Dates", "Distributed", "Mmap", "Sockets", "Test", "Unicode"]
git-tree-sha1 = "fec8e4d433072731466d37ed0061b3ba7f70eeb9"
git-tree-sha1 = "1f7a25b53ec67f5e9422f1f551ee216503f4a0fa"
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.19.0"
version = "0.20.0"

[[LazyArrays]]
deps = ["FillArrays", "LinearAlgebra", "StaticArrays", "Test"]
Expand Down Expand Up @@ -494,9 +494,9 @@ version = "0.4.2"

[[OffsetArrays]]
deps = ["DelimitedFiles", "Test"]
git-tree-sha1 = "f8cd140824f74f2948ff8660bc2292e16d29c1b7"
git-tree-sha1 = "f446248f2dfbc13039a0b90994dd25b059b01eab"
uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
version = "0.8.1"
version = "0.9.0"

[[Optim]]
deps = ["Calculus", "DiffEqDiffTools", "ForwardDiff", "LineSearches", "LinearAlgebra", "NLSolversBase", "NaNMath", "Parameters", "PositiveFactorizations", "Printf", "Random", "SparseArrays", "StatsBase", "Test"]
Expand Down Expand Up @@ -548,9 +548,9 @@ version = "0.1.2"

[[PerronFrobenius]]
deps = ["Conda", "Distributed", "Documenter", "InplaceOps", "LinearAlgebra", "Parameters", "Printf", "PyCall", "RecipesBase", "Reexport", "SharedArrays", "Simplices", "SparseArrays", "StateSpaceReconstruction", "StaticArrays", "Test"]
git-tree-sha1 = "5e43f20dc37812b364c00d09e52a64050a80de59"
git-tree-sha1 = "6c1471a5c3c36859c62e48d8b4c793ac16fae4d8"
uuid = "260eed61-d0e8-5f1e-b040-a9756a401c97"
version = "0.1.3"
version = "0.2.0"

[[Pkg]]
deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
Expand Down Expand Up @@ -718,16 +718,16 @@ uuid = "276daf66-3868-5448-9aa4-cd146d93841b"
version = "0.7.2"

[[StateSpaceReconstruction]]
deps = ["Conda", "Distributions", "DynamicalSystems", "DynamicalSystemsBase", "LinearAlgebra", "Parameters", "PyCall", "Reexport", "Simplices", "StaticArrays", "Statistics", "Test"]
git-tree-sha1 = "57019b8516555b32f25dd52c5e9e6dfd8786647e"
deps = ["Conda", "Distributions", "LinearAlgebra", "PyCall", "Reexport", "Simplices", "StaticArrays", "Statistics", "Test"]
git-tree-sha1 = "1137310fbd695e00b5bcdaf68677b6383e6e1151"
uuid = "1441a9f6-6a74-5418-a591-cdf1d78a07f0"
version = "0.2.3"
version = "0.3.0"

[[StaticArrays]]
deps = ["InteractiveUtils", "LinearAlgebra", "Random", "Statistics", "Test"]
git-tree-sha1 = "ebc5c2a27d91d5ec611a9861168182e2168effd3"
git-tree-sha1 = "97c4bf0f647488dd7ac01ea12be5885f88762938"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "0.9.2"
version = "0.10.0"

[[Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
Expand Down Expand Up @@ -791,9 +791,9 @@ version = "0.2.1"

[[TransferEntropy]]
deps = ["Conda", "Distances", "Distributions", "Interpolations", "NearestNeighbors", "PerronFrobenius", "PyCall", "Reexport", "Simplices", "SpecialFunctions", "StateSpaceReconstruction", "Test"]
git-tree-sha1 = "fee82641cbefd0a86a64c42023c78667529c733a"
git-tree-sha1 = "c335bef72a3ff612b54f30bc0df38bd8f7a51c04"
uuid = "ea221983-52f3-5440-99c7-13ea201cd633"
version = "0.2.3"
version = "0.3.1"

[[TreeViews]]
deps = ["Test"]
Expand Down
9 changes: 4 additions & 5 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
julia 0.7
julia 1.0
InplaceOps
DynamicalSystemsBase
DynamicalSystems
Expand All @@ -9,7 +9,6 @@ Plots
DifferentialEquations
TimeseriesSurrogates 0.2.1
Simplices 0.2.1
StateSpaceReconstruction 0.2.3 0.2.4
PerronFrobenius 0.1.3 0.1.4
TransferEntropy 0.2.3
DynamicalSystems
StateSpaceReconstruction 0.3.0
PerronFrobenius 0.2.0
TransferEntropy 0.3.1
22 changes: 13 additions & 9 deletions src/CausalityTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ using Statistics
using RecipesBase
using Plots

import DynamicalSystemsBase:
DynamicalSystem,
ContinuousDynamicalSystem,
DiscreteDynamicalSystem,
Dataset,
trajectory

@reexport using TimeseriesSurrogates
@reexport using StateSpaceReconstruction
@reexport using PerronFrobenius
@reexport using TransferEntropy
using StateSpaceReconstruction: GroupSlices

import DynamicalSystemsBase:
DynamicalSystem,
ContinuousDynamicalSystem,
DiscreteDynamicalSystem,
Dataset,
trajectory

# Example systems
include("systems/Systems.jl")

Expand All @@ -30,8 +31,11 @@ include("surrogates/surrogates.jl")
# Wrappers of the different methods.
include("method_wrappers/highlevel_methods.jl")

export Dataset,
DynamicalSystem, DiscreteDynamicalSystem, ContinuousDynamicalSystem,
trajectory
export
Dataset,
DynamicalSystem,
DiscreteDynamicalSystem,
ContinuousDynamicalSystem,
trajectory

end # module
14 changes: 8 additions & 6 deletions src/method_wrappers/transferentropy.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import StateSpaceReconstruction: embed

"""
te(driver, response;
estimator = :tetogrid,
Expand Down Expand Up @@ -109,22 +111,22 @@ function transferentropy(driver, response;
# computes conditional mutual information.
if !(typeof(E) == Embeddings.AbstractEmbedding) || !(typeof(v) == TEVars)
if dim == 3
E = embed([driver, response], [2, 2, 1], [ν, 0, 0])
E = StateSpaceReconstruction.embed([driver, response], [2, 2, 1], [ν, 0, 0])
v = TEVars([1], [2], [3])
elseif dim == 4
E = embed([driver, response], [2, 2, 2, 1], [ν, 0, -τ, 0])
E = StateSpaceReconstruction.embed([driver, response], [2, 2, 2, 1], [ν, 0, -τ, 0])
v = TEVars([1], [2, 3], [4])
elseif dim == 5
E = embed([driver, response], [2, 2, 2, 2, 1], [ν, 0, -τ, -2*τ, 0])
E = StateSpaceReconstruction.embed([driver, response], [2, 2, 2, 2, 1], [ν, 0, -τ, -2*τ, 0])
v = TEVars([1], [2, 3, 4], [5])
elseif dim == 6
E = embed([driver, response], [2, 2, 2, 2, 2, 1], [ν, 0, -τ, -2*τ, -3*τ, 0])
E = StateSpaceReconstruction.embed([driver, response], [2, 2, 2, 2, 2, 1], [ν, 0, -τ, -2*τ, -3*τ, 0])
v = TEVars([1], [2, 3, 4, 5], [6])
elseif dim == 7
E = embed([driver, response], [2, 2, 2, 2, 2, 2, 1], [ν, 0, -τ, -2*τ, -3*τ, -4*τ, 0])
E = StateSpaceReconstruction.embed([driver, response], [2, 2, 2, 2, 2, 2, 1], [ν, 0, -τ, -2*τ, -3*τ, -4*τ, 0])
v = TEVars([1], [2, 3, 4, 5, 6], [7])
elseif dim == 8
E = embed([driver, response], [2, 2, 2, 2, 2, 2, 2, 1], [ν, 0, -τ, -2*τ, -3*τ, -4*τ, -5*τ, 0])
E = StateSpaceReconstruction.embed([driver, response], [2, 2, 2, 2, 2, 2, 2, 1], [ν, 0, -τ, -2*τ, -3*τ, -4*τ, -5*τ, 0])
v = TEVars([1], [2, 3, 4, 5, 6, 7], [8])
end
end
Expand Down
41 changes: 21 additions & 20 deletions test/wrappers_te.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,50 @@ using Test, Distances
d1 = rand(50)
d2 = rand(50)
r = rand(50)
tol = 1e-8

# Directly from time series
te(d1, r, estimator = :tetogrid)
@test te(d1, r, estimator = :tetogrid) >= 0
@test te(d2, r, estimator = :tetogrid) >= 0
@test te(d1, r, estimator = :tefreq) >= 0
@test te(d2, r, estimator = :tefreq) >= 0
@test te(d1, r, estimator = :tekNN) >= 0
@test te(d2, r, estimator = :tekraskov) >= 0
@test te(d1, r, estimator = :tetogrid) >= 0 - tol
@test te(d2, r, estimator = :tetogrid) >= 0 - tol
@test te(d1, r, estimator = :tefreq) >= 0 - tol
@test te(d2, r, estimator = :tefreq) >= 0 - tol
@test te(d1, r, estimator = :tekNN) >= 0 - tol
@test te(d2, r, estimator = :tekraskov) >= 0 - tol

#########################
# Surrogates
#########################
@test te(d1, r, which_is_surr = :driver) >= 0
@test te(d1, r, which_is_surr = :response) >= 0
@test te(d1, r, which_is_surr = :none) >= 0
@test te(d1, r, which_is_surr = :driver) >= 0 - tol
@test te(d1, r, which_is_surr = :response) >= 0 - tol
@test te(d1, r, which_is_surr = :none) >= 0 - tol

@test te(d1, r, which_is_surr = :both, surr_func = aaft) >= 0
@test te(d1, r, which_is_surr = :both, surr_func = iaaft) >= 0
@test te(d1, r, which_is_surr = :both, surr_func = randomphases) >= 0
@test te(d1, r, which_is_surr = :both, surr_func = randomamplitudes) >= 0
@test te(d1, r, which_is_surr = :both, surr_func = randomshuffle) >= 0
@test te(d1, r, which_is_surr = :both, surr_func = aaft) >= 0 - tol
@test te(d1, r, which_is_surr = :both, surr_func = iaaft) >= 0 - tol
@test te(d1, r, which_is_surr = :both, surr_func = randomphases) >= 0 - tol
@test te(d1, r, which_is_surr = :both, surr_func = randomamplitudes) >= 0 - tol
@test te(d1, r, which_is_surr = :both, surr_func = randomshuffle) >= 0 - tol

#########################
# Forward prediction lags
#########################
@test te(d1, r, ν = 1) >= 0
@test te(d1, r, ν = 5) >= 0
@test te(d1, r, ν = 1) >= 0 - tol
@test te(d1, r, ν = 5) >= 0 - tol

#########################
# Embedding lags and dimensions
#########################
d1 = rand(100)
d2 = rand(100)
r = rand(100)
@test te(d1, r, ν = 1, τ = 2, dim = 4) >= 0
@test te(d1, r, ν = 3, τ = 3, dim = 5) >= 0
@test te(d1, r, ν = 1, τ = 2, dim = 4) >= 0 - tol
@test te(d1, r, ν = 3, τ = 3, dim = 5) >= 0 - tol

#########################
# Tuning the bins
#########################
@test te(d1, r, n_ϵ = 10) >= 0
@test te(d1, r, n_ϵ = 10, max_numbins = 5, min_numbins = 2) >= 0
@test te(d1, r, n_ϵ = 10) >= 0 - tol
@test te(d1, r, n_ϵ = 10, max_numbins = 5, min_numbins = 2) >= 0 - tol

end
# maxlag = 2
Expand Down

0 comments on commit 2fbb73a

Please sign in to comment.