-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsoftware_speed.py
50 lines (39 loc) · 1.41 KB
/
software_speed.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# speed test
# import required packages
from scipy.integrate import odeint
import numpy as np
import time
from rp import *
# the Roessler ODE
def roessler(x,t):
return [-(x[1] + x[2]), x[0] + 0.25 * x[1], 0.25 + (x[0] - 4) * x[2]]
# solve the ODE
x = odeint(roessler, [0, 0, 0], np.arange(0, 5500, .05))
# length of time series for RQA calculation test
N = np.round(10**np.arange(2.3,5.06,.075)). astype(int)
# calculate RP and RQA for different length
tspanRP = np.zeros(len(N)); # result vector computation time
tspanRQA = np.zeros(len(N)); # result vector computation time
K = 10; # number of runs (for averaging time)
maxT = 60; # stop calculations if maxT is exceeded
for i in range(0,len(tspanRP)):
tRP_ = 0
tRQA_ = 0
for j in range(0,K):
xe = embed(x[1000:(1000+N[i]),0], 3, 6)
start_time = time.time()
R = rp(xe, 1.2)
tRP_ += (time.time() - start_time)
start_time = time.time()
Q1 = np.mean(R)
Q2 = det(R, lmin=2, hist=None, verb=False)
Q3 = entr(R, lmin=2, hist=None, verb=False)
tRQA_ += (time.time() - start_time)
print(" ", j)
tspanRP[i] = tRP_ / K # average calculation time
tspanRQA[i] = tRQA_ / K # average calculation time
print(N[i], ": ", tspanRP[i], " ", tspanRQA[i])
if tspanRP[i] + tspanRQA[i] >= maxT:
break
tspanRP
np.savetxt('time_python_default.csv',list(zip(N, tspanRP, tspanRQA)))