pyEDM Examples
from pyEDM import *
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = [6, 3.5]
tentmap = sampleData['TentMap']
tentmapNoise = sampleData['TentMapNoise']
plt.plot( tentmap['TentMap'][1:40] );
Evaluate optimal embedding dimension (via Simplex)
EmbedDimension( dataFrame = tentmap, lib = "1 100", pred = "201 500",
columns = "TentMap", target = "TentMap" );
Optimal embedding dimension is E = 2
Evaluate decay in prediction versus Tp
PredictInterval( dataFrame = tentmap, lib = "1 100", pred = "251 500",
columns = "TentMap", target = "TentMap", E = 2 );
Decay in predictability as forecast interval increases is a possible indication of chaotic dynamics and nonlinearity provided there is insignificant serial correlation.
Simplex prediction
Simplex( dataFrame = tentmapNoise, lib = [1,500], pred = [501, 550],
columns = "TentMap", target = "TentMap", E = 2, showPlot = True );
Simplex Prediction using multivariate embedding
The block_3sp data frame is used directly as an embedding: embedded = True
block_3sp = sampleData['block_3sp']
block_3sp.head(3)
Simplex( dataFrame = block_3sp, lib = [1,99], pred = [100,195],
columns = "x_t y_t z_t", target = "x_t",
embedded = True, showPlot = True );
Evaluate optimal SMap theta parameter indicating state-dependence and extent of nonlinearity
PredictNonlinear( dataFrame = tentmapNoise, lib = [1,100], pred = [201,500],
columns = "TentMap", target = "TentMap", E = 2 );
SMap theta parameter in the range of [2-3] provides optimal resolution. The non-zero theta peak of predictability indicates nonlinearity.
SMap Prediction
SMap( dataFrame = tentmapNoise, lib = [1,500], pred = [501,550],
columns = "TentMap", target = "TentMap", E = 2, theta = 3, showPlot = True );
SMap Prediction multivariate embedding
Note SMap multivariate prediction requires embedded = True
SMap( dataFrame = sampleData[ 'circle' ],
lib = [1,100], pred = [110,190], theta = 4, E = 2,
embedded = True, columns = "x y", target = "x", showPlot = True );
Analytical solution of the SMap coefficients are C0 = 0; ∂x/∂x = 0.998; ∂x/∂y = 0.063. Deviations from these values are due to sampling and numerical noise.
Inference of causality via Convergent Cross Mapping (CCM)
sardine_anchovy_sst = sampleData['sardine_anchovy_sst']
sardine_anchovy_sst[['anchovy','np_sst']].plot(lw=2);
CCM( dataFrame = sardine_anchovy_sst, E = 3,
columns = "anchovy", target = "np_sst",
libSizes = [10,70,10], sample = 30,
seed = 12345, showPlot = True );
The CCM result anchovy:np_sst is interpreted as: sea surface temperature (np_sst) influences anchovy population. The reverse influence (np_sst:anchovy) indicates no link consistent with the fact that anchovy population does not influence sea surface temperature.
Multiview Embedding
MV = Multiview( dataFrame = block_3sp, lib = [1,99], pred = [105,190], E = 3,
columns = "x_t y_t z_t", target = "x_t", showPlot = True );
MV['View']
# Col_i are column indices in block_3sp