2. Examples - adam-zlatniczki/dimensional_causality GitHub Wiki

In this example we generate two random, independent uniform time-series and check their causal relation. We expect the final probabilities to be [0.026, 0.069, 0.016, 0.118, 0.771] (very slight differences are acceptable, since the time-permuted manifold Z is constructed randomly). Running the demo should take a couple of seconds only.

2.1 - C++

2.2 - Python

import numpy as np
import dimensional_causality as dc

np.random.seed(0)
x = np.random.rand(10000)
y = np.random.rand(10000)
k_range = range(10, 40, 2)

probs, dims, stdevs = dc.infer_causality(x, y, 4, 1, k_range)
print(probs)

2.3 - R

library(dimensionalcausality)

set.seed(0)
x <- runif(10000)
y <- runif(10000)
k_range <- seq(10, 40, 2)

ret <- infer_causality(x, y, 4, 1, k_range)
print(ret$probs)