Hao Ye 10/3/2019
pip install .
python min_working_example.py
set.seed(42)
nile <- as.numeric(Nile)
ss_m <- as.numeric(sunspot.month)
ss_y <- as.numeric(sunspot.year)
test <- c(1, 1, 0, 0, 1, 1, rnorm(100))
Josh’s cython implementation:
import ordinal_TSA
import numpy as np
ts = np.vstack(np.asarray(r.nile))
ordinal_TSA.permutation_entropy(ts, dim = 3, step = 1, w = 1)
## 0.9853334990868959
ts = np.vstack(np.asarray(r.ss_m))
ordinal_TSA.permutation_entropy(ts, dim = 3, step = 1, w = 1)
## 0.9746485154549505
ts = np.vstack(np.asarray(r.ss_y))
ordinal_TSA.permutation_entropy(ts, dim = 3, step = 1, w = 1)
## 0.5718737881018081
Frank’s R implementation:
library(MATSSforecasting)
PE(nile, weighted = TRUE, tie_method = "first", word_length = 3, tau = 1)
## [1] 0.9853335
PE(ss_m, weighted = TRUE, tie_method = "first", word_length = 3, tau = 1)
## [1] 0.9746485
PE(ss_y, weighted = TRUE, tie_method = "first", word_length = 3, tau = 1)
## [1] 0.5718738
Check how ties should be handled for consistency
import ordinal_TSA
import numpy as np
ts = np.vstack(np.asarray(r.test))
ordinal_TSA.permutation_entropy(ts, dim = 3, step = 1, w = 1)
## 0.9972149151169224
library(MATSSforecasting)
PE(test, weighted = TRUE, tie_method = "first", word_length = 3, tau = 1)
## [1] 0.9972149
PE(test, weighted = TRUE, tie_method = "last", word_length = 3, tau = 1)
## [1] 0.9974512
PE(test, weighted = TRUE, tie_method = "average", word_length = 3, tau = 1)
## [1] 0.7453637
PE(test, weighted = TRUE, tie_method = "random", word_length = 3, tau = 1)
## [1] 0.9972529
PE(test, weighted = TRUE, tie_method = "noise", word_length = 3, tau = 1, noise_amount = 5)
## [1] 0.7193993
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.