diff --git a/Code_Python/filters.py b/Code_Python/filters.py index 74373b6..abbc32c 100644 --- a/Code_Python/filters.py +++ b/Code_Python/filters.py @@ -4,11 +4,39 @@ Class for filter/smooth data. Copyright (c) 2020 Gabriele Gilardi -ToDo: -- generalize to multidimensional input arrays -- use NaN or input values for points not filtered? -- plot filtered data -- add plot filter +N = order/smoothing factor/number of past bars + alpha = damping term + +General b,a Generic case (param = [b; a]) +SMA N Simple Moving Average +EMA N Exponential Moving Average +PassBand P,delta Pass band filter +StopBand P,delta Stop band filter +InstTrendline alpha Instantaneous trendline +GaussLow P,N Gauss, low pass (must be P > 1) +ZEMA1 N,K,Vn Zero-lag EMA (type 1) + +ZEMA2 N,K Zero-lag EMA (type 2) +LWMA N Linearly Weighted Moving Average +MSMA N Modified Simple Moving Average +MLSQ N Modified Least-Squares Quadratic +GaussHigh P,N Gauss, high pass (must be P > 4) +ButterOrig P,N Butterworth original, order N (2 or 3) +ButterMod P,N Butterworth modified, order N (2 or 3) +SuperSmoother P, N Super smoother +SincFunction N Sinc function (N > 1, cut off at 0.5/N) + +b Coefficients at the numerator +a Coefficients at the denominator +P Cut of period (50% power loss, -3 dB) +N Order/smoothing factor +K Coefficient/gain +Vn Look back bar for the momentum +delta Band centered in P and in percent + (0.3 => 30% of P, = 0.3*P, if P = 10 => 0.3*10 = 3) +alpha Damping term +nt Times the filter is called (order) + """ @@ -16,45 +44,44 @@ import sys import numpy as np -def Generalized(X, b, a): +def filter_data(X, b, a): """ - Applies a generic filter + Applies a generic filter. Inputs: - X Data to filter + X (n_samples, n_series) Data to filter b Transfer response coefficients (numerator) a Transfer response coefficients (denominator) Outputs: Y Filtered data - idx Index first element in Y actually filtered + idx Index of the first element in Y filtered - Elements from 0 to (idx-1) are set equal to NaN. + Notes: + - the filter is applied from element 0 to len(X). + - elements from 0 to (idx-1) are set equal to the original input. """ - # Initialize - nel_X = len(X) - nel_b = len(b) - nel_a = len(a) - idx = np.amax([0, nel_b-1, nel_a-1]) + n_samples, n_series = X.shape + Nb = len(b) + Na = len(a) + idx = np.amax([0, Nb-1, Na-1]) Y = X.copy() # Apply filter - for i in range(idx, nel_X): - tmp = 0.0 + for i in range(idx, n_samples): + + tmp = np.zeros(n_series) # Contribution from [b] (numerator) - for j in range(nel_b): - tmp = tmp + b[j] * X[i-j] + for j in range(Nb): + tmp = tmp + b[j] * X[i-j,:] # Contribution from [a] (denominator) - for j in range(1, nel_a): - tmp = tmp - a[j] * Y[i-j] + for j in range(1, Na): + tmp = tmp - a[j] * Y[i-j, :] # Filtered value - Y[i] = tmp / a[0] - - # Set elements from 0 to (idx-1) equal to NaN - Y[0:idx] = np.nan + Y[i,:] = tmp / a[0] return Y, idx @@ -63,57 +90,58 @@ class Filter: def __init__(self, X): """ + X (nel_X, ) Data to filter """ self.X = np.asarray(X) - self.nel = len(X) + self.n_samples, self.n_series = X.shape self.idx = 0 def SMA(self, N=10): """ - Simple Moving Average - N = order/smoothing factor + Simple moving average (type ???). """ - b = np.ones(float(N)) / float(N) + b = np.ones(N) / N a = np.array([1.0]) - Y, self.idx = Generalized(self.X, b, a) + Y, self.idx = filter_data(self.X, b, a) return Y - def EMA(self, N=10): + def EMA(self, N=10, alpha=None): """ - Exponential Moving Average - N = order/smoothing factor - The damping term is determined as equivalent to a N-SMA + Exponential moving average (type ???). + + If is not given it is determined as equivalent to a N-SMA. """ - alpha = 2.0 / (float(N) + 1.0) + if (alpha is None): + alpha = 2.0 / (N + 1.0) b = np.array([alpha]) - a = np.array([1.0, alpha-1.0]) - Y, self.idx = Generalized(self.X, b, a) + a = np.array([1.0, alpha - 1.0]) + Y, self.idx = filter_data(self.X, b, a) return Y def InstTrend(self, alpha=0.5): """ - Instantaneous Trendline (2nd order, IIR, low pass, Ehlers) - alpha = damping term + Instantaneous Trendline (2nd order, IIR, low pass, Ehlers.) """ - b = np.array([(alpha-alpha**2/4.0), (alpha**2/2.0), - -(alpha-3.0*alpha**2/4.0)]) - a = np.array([1.0, -2.0*(1.0-alpha), (1.0-alpha)**2]) - Y, self.idx = Generalized(self.X, b, a) + b = np.array([alpha - alpha ** 2.0 / 4.0, alpha ** 2.0 / 2.0, + - alpha + 3.0 * alpha ** 2.0 / 4.0]) + a = np.array([1.0, - 2.0 * (1.0 - alpha), (1.0 - alpha) ** 2.0]) + Y, self.idx = filter_data(self.X, b, a) return Y def PassBand(self, P=5, delta=0.3): """ - Pass Band + Pass Band (type ???). + P = cut-off period (50% power loss, -3 dB) delta = band centered in P and in percent (Example: 0.3 => 30% of P => 0.3*P, if P = 10 => 0.3*10 = 3) """ - beta = np.cos(2.0 * pi / float(P)) - gamma = np.cos(2.0*pi*(2.0*delta)/float(P)) + beta = np.cos(2.0 * np.pi / P) + gamma = np.cos(4.0 * np.pi * delta) / P alpha = 1.0 / gamma - np.sqrt(1.0 / gamma ** 2 - 1.0) - b = np.array([(1.0-alpha)/2.0, 0.0, -(1.0-alpha)/2.0]) - a = np.array([1.0, -beta*(1.0+alpha), alpha]) - Y, self.idx = Generalized(self.X, b, a) + b = np.array([(1.0 - alpha) / 2.0, 0.0, - (1.0 - alpha) / 2.0]) + a = np.array([1.0, - beta * (1.0 + alpha), alpha]) + Y, self.idx = filter_data(self.X, b, a) return Y def StopBand(self, P=5, delta=0.3): @@ -166,3 +194,13 @@ class Filter: a = np.array([1.0, -(1.0-alpha)]) Y, self.idx = Generalized(self.X, b, a) return Y + + def Generalized(self, a, b): + """ + Generic filter with transfer response coefficients and + """ + b = np.asarray(b) + a = np.asarray(a) + Y, self.idx = filter_data(self.X, b, a) + return Y + diff --git a/Code_Python/sine_fast.csv b/Code_Python/sine_fast.csv new file mode 100644 index 0000000..4744f24 --- /dev/null +++ b/Code_Python/sine_fast.csv @@ -0,0 +1,500 @@ +107.0614811 +107.7330878 +108.327428 +108.8385632 +109.2613865 +109.5916731 +109.8261228 +109.9623932 +109.9991226 +109.9359441 +109.7734889 +109.5133803 +109.1582171 +108.711548 +108.177836 +107.5624138 +106.8714305 +106.1117901 +105.2910827 +104.4175085 +103.4997961 +102.5471148 +101.5689837 +100.5751757 +99.57562082 +98.58030618 +97.59917665 +96.64203535 +95.71844572 +94.83763597 +94.00840685 +93.23904375 +92.53723389 +91.90998952 +91.36357787 +90.90345849 +90.53422874 +90.25957785 +90.08225004 +90.00401711 +90.02566074 +90.14696467 +90.36671687 +90.68272165 +91.09182159 +91.58992911 +92.17206728 +92.83241956 +93.56438794 +94.36065883 +95.21327615 +96.11372083 +97.05299593 +98.02171652 +99.01020346 +100.0085801 +101.0068711 +101.9951017 +102.9633979 +103.9020848 +104.8017834 +105.6535041 +106.4487369 +107.1795361 +107.8385997 +108.4193426 +108.9159622 +109.3234965 +109.6378735 +109.855952 +109.9755531 +109.9954818 +109.915539 +109.7365233 +109.4602235 +109.0894003 +108.6277588 +108.0799116 +107.4513326 +106.7483024 +105.9778453 +105.1476596 +104.2660402 +103.3417959 +102.3841615 +101.4027053 +100.4072338 +99.40769329 +98.41407094 +97.43629467 +96.4841341 +95.5671029 +94.69436374 +93.87463674 +93.11611235 +92.42636949 +91.81229984 +91.28003899 +90.8349051 +90.48134581 +90.22289377 +90.06213134 +90.00066481 +90.03910833 +90.17707779 +90.41319464 +90.74509968 +91.16947663 +91.68208524 +92.27780371 +92.95067982 +93.6939904 +94.50030854 +95.36157778 +96.26919261 +97.21408443 +98.18681219 +99.17765673 +100.1767179 +101.1740133 +102.1595783 +103.1235656 +104.0563432 +104.9485912 +105.7913945 +106.5763321 +107.2955612 +107.9418954 +108.5088769 +108.9908404 +109.3829705 +109.681349 +109.8829947 +109.9858927 +109.989015 +109.8923304 +109.6968049 +109.4043921 +109.0180138 +108.5415304 +107.9797029 +107.3381448 +106.6232664 +105.8422105 +105.0027812 +104.1133657 +103.1828509 +102.220534 +101.2360304 +100.2391767 +99.23993321 +98.24828408 +97.27413753 +96.32722688 +95.41701338 +94.55259156 +93.74259844 +92.99512721 +92.31764636 +91.71692504 +91.19896547 +90.76894293 +90.43115406 +90.18897394 +90.04482234 +90.00013959 +90.05537214 +90.20996812 +90.46238287 +90.81009433 +91.24962829 +91.77659307 +92.38572342 +93.07093311 +93.82537573 +94.64151317 +95.51119083 +96.42571919 +97.37596058 +98.35242051 +99.3453425 +100.3448056 +101.3408236 +102.3234444 +103.2828502 +104.2094548 +105.094 +105.9276476 +106.702068 +107.4095237 +108.0429458 +108.5960055 +109.0631767 +109.4397917 +109.7220873 +109.9072431 +109.993409 +109.9797241 +109.866325 +109.6543449 +109.3459018 +108.9440775 +108.452887 +107.877238 +107.2228822 +106.4963578 +105.7049239 +104.8564883 +103.9595283 +103.023006 +102.0562788 +101.069006 +100.071052 +99.07238803 +98.08299249 +97.11275106 +96.17135806 +95.26821959 +94.4123595 +93.61232928 +92.87612254 +92.21109524 +91.62389209 +91.12038025 +90.70559063 +90.38366768 +90.15782795 +90.03032794 +90.0024416 +90.07444756 +90.24562636 +90.51426763 +90.87768721 +91.33225392 +91.87342589 +92.4957959 +93.19314543 +93.95850681 +94.78423278 +95.66207298 +96.58325632 +97.53857862 +98.51849464 +99.51321336 +100.5127959 +101.5072548 +102.4866536 +103.4412067 +104.3613763 +105.2379685 +106.0622247 +106.8259091 +107.5213913 +108.1417222 +108.6807037 +109.1329505 +109.4939439 +109.760077 +109.9286906 +109.9980999 +109.9676116 +109.8375302 +109.6091554 +109.2847692 +108.8676126 +108.3618537 +107.772546 +107.1055775 +106.3676125 +105.5660244 +104.7088224 +103.8045714 +102.8623064 +101.8914422 +100.9016793 +99.90290715 +98.9051051 +97.91824288 +96.95218089 +96.0165717 +95.12076361 +94.27370723 +93.48386608 +92.75913199 +92.10674625 +91.5332273 +91.04430554 +90.64486612 +90.33890011 +90.12946461 +90.01865224 +90.0075702 +90.09632921 +90.28404242 +90.56883428 +90.94785922 +91.41733016 +91.97255631 +92.60799001 +93.31728224 +94.09334597 +94.92842704 +95.81418159 +96.74175945 +97.70189258 +98.68498763 +99.68122185 +100.6806412 +101.6732598 +102.6491598 +103.5985902 +104.5120647 +105.3804561 +106.1950878 +106.9478202 +107.6311323 +108.2381967 +108.7629477 +109.2001423 +109.545412 +109.7953072 +109.9473309 +109.9999641 +109.952681 +109.805954 +109.5612492 +109.2210115 +108.7886405 +108.2684563 +107.6656565 +106.9862639 +106.2370669 +105.4255512 +104.5598252 +103.6485389 +102.7007976 +101.7260708 +100.7340978 +99.7347898 +98.73813174 +97.75408184 +96.79247242 +95.86291156 +94.97468712 +94.13667394 +93.35724517 +92.64418862 +92.0046289 +91.44495629 +90.97076285 +90.58678656 +90.29686399 +90.10389194 +90.00979854 +90.01552392 +90.12101089 +90.32520546 +90.62606737 +91.02059052 +91.50483296 +92.0739563 +92.72227405 +93.44330843 +94.22985511 +95.07405517 +95.96747364 +96.90118378 +97.86585627 +98.85185241 +99.84932047 +100.8482941 +101.8387918 +102.8109169 +103.7549563 +104.6614774 +105.5214225 +106.3261994 +107.0677671 +107.7387159 +108.332342 +108.8427142 +109.2647328 +109.5941813 +109.827768 +109.9631588 +109.999001 +109.9349365 +109.7716054 +109.5106397 +109.1546468 +108.7071837 +108.1727212 +107.5565997 +106.8649751 +106.104758 +105.2835441 +104.4095388 +103.4914748 +102.5385252 +101.5602115 +100.5663086 +99.56674743 +98.57151513 +97.59055579 +96.63367081 +95.71042109 +94.83003142 +94.00129836 +93.23250235 +92.53132494 +91.90477207 +91.35910403 +90.89977297 +90.53136837 +90.25757121 +90.08111717 +90.00376934 +90.02630053 +90.14848564 +90.36910382 +90.68595073 +91.09586054 +91.59473757 +92.1775972 +92.8386157 +93.57118838 +94.36799563 +95.22107599 +96.12190579 +97.06148422 +98.03042334 +99.01904181 +100.0174617 +101.0157071 +102.0038039 +102.9718793 +103.9102608 +104.8095721 +105.6608279 +106.4555225 +107.1857156 +107.8441115 +108.4241316 +108.9199806 +109.326704 +109.6402381 +109.8574502 +109.9761699 +109.9952109 +109.9143831 +109.7344941 +109.4573413 +109.0856938 +108.623265 +108.0746755 +107.4454065 +106.7417454 +105.970723 +105.1400431 +104.2580057 +103.3334236 +102.3755351 +101.393911 +100.3983594 +99.39882755 +98.4053024 +97.42771095 +96.47582096 +95.5591434 +94.68683741 +93.86761879 +93.10967289 +92.42057287 +91.80720397 +91.27569478 +90.83135597 +90.47862722 +90.22103288 +90.06114674 +90.00056634 +90.03989698 +90.17874567 +90.41572509 +90.74846742 +91.173648 +91.68701858 +92.28344971 +92.95698207 +93.70088593 +94.50772846 +95.36944795 +96.27743439 +97.22261547 +98.19554726 +99.18650854 +100.185598 +101.182833 +102.1682495 +103.1320015 +104.0644597 diff --git a/Code_Python/sine_fast_noise.csv b/Code_Python/sine_fast_noise.csv new file mode 100644 index 0000000..d050cea --- /dev/null +++ b/Code_Python/sine_fast_noise.csv @@ -0,0 +1,500 @@ +99.74607254 +100.9985047 +105.6589958 +110.3758689 +111.4562084 +120.2469638 +92.47859905 +99.7988658 +111.3608434 +97.95849713 +116.4332767 +120.4499707 +109.0983808 +109.6064832 +109.6401406 +109.901406 +99.27412717 +85.79481934 +98.4200087 +103.7514383 +106.6847133 +82.19057649 +98.78947827 +98.48496831 +113.8385423 +90.1639471 +78.93094346 +99.02728187 +86.61426422 +91.37872779 +90.99097198 +86.27464383 +90.68010168 +97.21054672 +106.2564401 +83.25943317 +93.71136548 +92.17605257 +75.2199172 +91.33571727 +92.71473597 +88.49934963 +95.88603552 +100.5548966 +83.65217931 +64.61541321 +95.02446505 +104.0182222 +96.86731681 +96.7533356 +102.581885 +101.1446821 +119.619968 +99.10202402 +80.48133979 +102.0149845 +88.5733381 +113.6041862 +89.36855047 +96.11116099 +117.5312372 +117.8596423 +99.58612933 +101.364107 +100.9620158 +119.1091278 +100.8018557 +113.2488968 +101.8717012 +125.2536113 +108.9875467 +104.0605359 +99.13376678 +115.6371565 +117.0847191 +109.0894949 +116.900752 +109.8769949 +110.1912392 +105.9834098 +113.290719 +103.6682498 +114.0142086 +106.8546324 +100.9786188 +112.6259146 +105.0708015 +86.57901721 +86.16099103 +95.71501275 +95.32165336 +72.33052217 +79.04885583 +97.64257546 +98.83452607 +105.4753737 +82.66939704 +94.38495045 +95.62961653 +101.0090845 +102.2562397 +89.37424999 +87.00897709 +98.34732987 +87.17473187 +88.29022085 +98.71513962 +94.13589388 +80.98525401 +90.0555734 +105.663407 +91.85344181 +104.7828486 +94.72801184 +98.85182601 +85.84903801 +97.12691481 +103.1898604 +97.53009653 +100.77248 +96.8109706 +88.20273689 +91.28975471 +103.3826265 +100.9843703 +125.2089148 +117.6572149 +102.3665879 +98.09826068 +115.6305485 +98.2446131 +113.5826621 +98.52151793 +96.54353022 +110.0970167 +119.0894679 +82.70969544 +105.5948041 +108.1286679 +114.7791846 +96.55073367 +108.9916162 +103.6793435 +104.9947092 +111.5026331 +120.0264838 +86.72900841 +107.0418354 +110.8793625 +93.15449934 +92.0470496 +93.10674393 +115.028515 +94.87926251 +80.65842088 +90.26230642 +94.37404315 +90.41820803 +79.3694285 +104.7989829 +89.06354298 +74.92484744 +88.55520858 +88.17327988 +92.44427227 +106.2241627 +89.69936655 +110.1258867 +81.40795851 +79.50154712 +102.8429063 +91.98680097 +102.6747939 +87.29859659 +105.5483568 +98.71704962 +89.0729352 +107.3147853 +99.52825529 +90.68454466 +95.79189223 +106.4811685 +106.5963564 +91.72663379 +85.5984658 +107.1724503 +97.48127236 +100.7599682 +112.8430896 +95.08863157 +94.24392767 +122.5515637 +93.0184012 +126.8264613 +106.5008815 +107.1326088 +98.20586297 +119.7951298 +120.5518721 +104.4271292 +98.12433617 +119.4486154 +117.2844245 +98.65840409 +104.769913 +101.1362625 +101.6987705 +115.5489754 +103.7431279 +126.2359309 +101.432232 +115.0751813 +89.36542689 +95.37135596 +101.3991848 +112.1568858 +113.3831319 +92.53006936 +106.1232446 +94.13544376 +91.43306306 +104.9240959 +84.89509638 +99.068661 +104.8793253 +84.08844816 +90.63766684 +79.86846014 +89.03795827 +106.3052081 +104.302822 +89.86796622 +100.0547195 +87.27556042 +86.13651022 +84.52982443 +89.04938259 +88.45288282 +93.9221361 +77.90453416 +89.11116191 +103.8236699 +100.5704991 +105.0038536 +82.48819192 +90.70077556 +93.20727118 +96.469969 +124.0621945 +126.208824 +113.8096177 +116.2336238 +98.2431384 +104.3742794 +110.8824523 +82.66158983 +93.36370081 +94.50577091 +109.2124186 +108.6860623 +102.2125708 +92.7364688 +117.8992898 +111.8389321 +116.1499254 +103.7510718 +106.1711274 +115.8905823 +94.9394883 +111.3292051 +119.6381222 +92.55331545 +94.6690993 +98.14521121 +103.3060014 +83.8533364 +110.1232204 +86.89602288 +84.7500101 +81.00671318 +111.9346161 +72.63786168 +108.923088 +67.93841767 +81.28708323 +108.8012014 +86.33287375 +90.99581497 +115.0077996 +75.6884257 +92.27903243 +96.95099649 +73.17740219 +81.23584289 +108.1412357 +85.2937767 +73.67059556 +99.09771683 +86.41655575 +65.50046252 +77.50463602 +107.5223067 +97.43228837 +97.24231792 +92.36343746 +102.3239382 +107.6653067 +84.70401863 +102.1418889 +110.6478756 +110.8038522 +121.8958125 +116.6996419 +126.1771719 +102.6189077 +106.3284051 +104.7333304 +103.7911867 +110.1573359 +117.8848836 +110.7704487 +119.4976273 +99.29985521 +111.778141 +123.775525 +94.96070742 +113.0174536 +101.3223299 +112.8532801 +111.4698438 +98.0466213 +100.9512001 +112.8041168 +109.1341396 +110.2363954 +107.752259 +90.56497789 +95.08630261 +100.6715567 +102.8404892 +85.11606497 +87.83600724 +111.9823882 +90.93281134 +100.7576002 +104.9842738 +85.7248994 +72.57166009 +106.7911372 +83.80974127 +83.42667246 +103.4631772 +91.94917091 +89.44543328 +97.38905178 +85.58235769 +99.69552244 +92.69614929 +89.05675883 +79.6668893 +103.2663666 +89.02871412 +92.60746955 +78.08256782 +87.87930204 +106.0975357 +101.2546742 +95.97578469 +106.3580882 +105.5082865 +105.8051223 +109.3086288 +88.2841571 +107.1446562 +105.0249265 +91.34560811 +101.6362066 +97.97629225 +107.398384 +113.9392197 +106.0515676 +107.7642295 +107.9836656 +108.8387993 +130.8390171 +107.8067205 +104.2591576 +101.600015 +113.5900125 +134.1875781 +101.7261452 +92.00590968 +106.4209836 +102.6942079 +105.7008816 +103.9306204 +116.200302 +89.28654287 +98.26692557 +109.0136698 +110.6672568 +108.8077604 +90.38695194 +110.8817082 +103.4241109 +107.4745031 +90.91627193 +107.7650809 +94.89064041 +93.08468827 +111.8944482 +83.89803856 +92.31150457 +87.05840489 +85.72434748 +92.87781938 +92.677094 +92.16102828 +88.39332676 +78.57679378 +80.14248863 +99.90498722 +80.40409998 +94.60128577 +100.937819 +69.68454717 +79.35756318 +109.0345368 +97.2767808 +94.59856421 +99.47823966 +91.72744188 +89.55714145 +101.822452 +98.00835693 +100.9320037 +109.2875592 +109.663176 +91.50602111 +91.41620387 +108.7803863 +112.0525174 +94.71657797 +118.9798346 +112.2837288 +113.3716799 +121.3109877 +108.8753364 +115.4845303 +99.15231977 +102.6315514 +88.44010676 +103.2309702 +116.0166296 +100.8031655 +97.7434958 +107.4554646 +116.3636227 +97.52347706 +107.7511089 +90.12846298 +92.07561775 +96.17594686 +110.4881757 +99.48994336 +93.41407809 +77.49294169 +98.7835899 +88.90963562 +93.10638765 +95.05029833 +95.40861665 +75.66158751 +101.0185954 +78.31471081 +107.98879 +92.65178182 +97.7014015 +103.3937285 +97.54252609 +87.2119731 +90.3813286 +69.14035241 +92.06857878 +75.30933914 +95.78452738 +79.05232302 +77.2929126 +78.5735926 +86.2639689 +103.8629931 +114.2854047 +109.9225833 +108.1768798 +83.15688423 +121.5107716 +84.33275404 +103.371499 +104.8325784 +93.06763 diff --git a/Code_Python/sine_slow.csv b/Code_Python/sine_slow.csv new file mode 100644 index 0000000..0917159 --- /dev/null +++ b/Code_Python/sine_slow.csv @@ -0,0 +1,500 @@ +107.0742605 +106.8347785 +106.5877031 +106.3333087 +106.0718779 +105.8037012 +105.5290765 +105.248309 +104.9617106 +104.6695997 +104.3723008 +104.0701443 +103.7634657 +103.452606 +103.1379104 +102.8197285 +102.4984139 +102.1743235 +101.8478174 +101.5192584 +101.1890115 +100.8574436 +100.5249231 +100.1918193 +99.8585025 +99.52534286 +99.19271057 +98.86097518 +98.53050526 +98.20166796 +97.87482862 +97.55035036 +97.22859368 +96.90991606 +96.59467155 +96.28321039 +95.97587861 +95.67301766 +95.37496402 +95.08204884 +94.79459755 +94.51292949 +94.23735762 +93.96818809 +93.70571995 +93.45024482 +93.20204651 +92.96140078 +92.728575 +92.50382783 +92.28740897 +92.07955886 +91.88050842 +91.69047881 +91.50968115 +91.3383163 +91.17657465 +91.02463589 +90.88266885 +90.75083123 +90.62926951 +90.51811876 +90.41750245 +90.32753238 +90.24830849 +90.17991882 +90.12243934 +90.0759339 +90.04045419 +90.01603962 +90.0027173 +90.00050205 +90.00939633 +90.02939025 +90.0604616 +90.10257585 +90.15568623 +90.21973372 +90.29464716 +90.38034334 +90.47672703 +90.58369115 +90.70111688 +90.82887374 +90.96681979 +91.11480178 +91.2726553 +91.44020498 +91.61726465 +91.80363762 +91.99911681 +92.20348504 +92.41651527 +92.63797081 +92.86760563 +93.1051646 +93.35038379 +93.60299075 +93.86270484 +94.12923752 +94.40229267 +94.68156691 +94.96674998 +95.25752503 +95.55356901 +95.85455301 +96.16014263 +96.46999837 +96.78377597 +97.10112682 +97.42169834 +97.74513438 +98.07107559 +98.39915985 +98.72902266 +99.06029754 +99.39261643 +99.72561013 +100.0589087 +100.3921418 +100.7249392 +101.0569312 +101.387749 +101.7170249 +102.0443933 +102.3694903 +102.6919547 +103.0114284 +103.3275564 +103.6399874 +103.9483743 +104.2523746 +104.5516505 +104.8458694 +105.1347046 +105.417835 +105.6949462 +105.9657302 +106.2298863 +106.4871209 +106.7371483 +106.9796907 +107.2144785 +107.441251 +107.6597562 +107.8697514 +108.0710032 +108.2632881 +108.4463923 +108.6201126 +108.7842558 +108.9386397 +109.0830927 +109.2174542 +109.3415752 +109.4553175 +109.5585549 +109.6511727 +109.7330679 +109.8041496 +109.8643389 +109.9135687 +109.9517845 +109.9789438 +109.9950164 +109.9999845 +109.9938425 +109.9765972 +109.9482679 +109.908886 +109.8584952 +109.7971515 +109.7249232 +109.6418903 +109.5481453 +109.4437921 +109.3289469 +109.2037371 +109.0683018 +108.9227916 +108.7673682 +108.6022041 +108.4274829 +108.2433986 +108.0501559 +107.8479694 +107.6370638 +107.4176733 +107.1900417 +106.9544219 +106.7110757 +106.4602735 +106.2022938 +105.9374233 +105.6659563 +105.3881943 +105.1044461 +104.8150267 +104.5202579 +104.220467 +103.9159871 +103.6071565 +103.2943183 +102.9778201 +102.6580136 +102.3352539 +102.0098998 +101.6823127 +101.3528564 +101.0218972 +100.6898026 +100.3569417 +100.0236842 +99.69040033 +99.35746047 +99.02523447 +98.69409145 +98.3643993 +98.03652432 +97.71083078 +97.38768052 +97.06743257 +96.75044272 +96.43706316 +96.12764206 +95.82252317 +95.5220455 +95.22654287 +94.93634359 +94.65177007 +94.37313849 +94.10075839 +93.83493239 +93.57595584 +93.32411646 +93.07969403 +92.84296013 +92.61417775 +92.39360108 +92.18147519 +91.97803573 +91.78350875 +91.59811036 +91.42204654 +91.25551289 +91.09869444 +90.95176541 +90.81488905 +90.68821742 +90.57189126 +90.4660398 +90.37078066 +90.28621965 +90.21245074 +90.14955587 +90.09760493 +90.05665563 +90.02675346 +90.00793166 +90.00021112 +90.00360044 +90.01809583 +90.04368121 +90.08032813 +90.1279959 +90.18663154 +90.25616991 +90.33653376 +90.4276338 +90.52936882 +90.64162579 +90.76427999 +90.89719515 +91.0402236 +91.19320643 +91.35597369 +91.52834453 +91.71012745 +91.90112048 +92.10111144 +92.30987813 +92.5271886 +92.75280144 +92.98646596 +93.22792259 +93.47690304 +93.73313071 +93.99632093 +94.26618128 +94.54241195 +94.82470605 +95.11274994 +95.4062236 +95.70480099 +96.00815038 +96.31593475 +96.62781215 +96.94343607 +97.26245586 +97.58451709 +97.90926193 +98.23632961 +98.56535673 +98.89597776 +99.22782537 +99.56053086 +99.89372461 +100.2270364 +100.560096 +100.8925333 +101.223979 +101.5540649 +101.8824242 +102.208692 +102.532506 +102.8535064 +103.1713365 +103.4856432 +103.7960774 +104.1022941 +104.4039531 +104.7007192 +104.9922628 +105.27826 +105.558393 +105.8323506 +106.0998283 +106.3605292 +106.6141634 +106.8604492 +107.099113 +107.3298897 +107.5525227 +107.7667649 +107.9723781 +108.1691339 +108.3568138 +108.5352092 +108.7041219 +108.8633642 +109.0127593 +109.1521411 +109.2813548 +109.4002568 +109.5087151 +109.6066092 +109.6938302 +109.7702812 +109.8358775 +109.8905459 +109.9342259 +109.9668689 +109.9884386 +109.9989111 +109.9982747 +109.9865302 +109.9636905 +109.9297811 +109.8848396 +109.828916 +109.7620723 +109.684383 +109.5959342 +109.4968242 +109.3871632 +109.2670729 +109.1366869 +108.99615 +108.8456182 +108.6852589 +108.5152502 +108.335781 +108.1470506 +107.9492689 +107.7426554 +107.5274397 +107.3038611 +107.0721677 +106.8326171 +106.5854755 +106.3310173 +106.0695253 +105.80129 +105.5266095 +105.2457888 +104.95914 +104.6669816 +104.3696381 +104.0674399 +103.7607227 +103.4498274 +103.1350992 +102.816888 +102.4955471 +102.1714337 +101.8449078 +101.5163322 +101.186072 +100.854494 +100.5219666 +100.1888594 +99.85554228 +99.5223857 +99.18975974 +98.85803397 +98.52757694 +98.19875578 +97.87193581 +97.54748015 +97.22574925 +96.90710057 +96.59188812 +96.28046212 +95.97316855 +95.67034882 +95.37233938 +95.0794713 +94.79206997 +94.51045469 +94.23493835 +93.96582703 +93.70341973 +93.44800798 +93.19987555 +92.95929812 +92.72654296 +92.50186867 +92.28552487 +92.07775191 +91.87878064 +91.68883211 +91.50811735 +91.33683715 +91.17518179 +91.02333087 +90.88145311 +90.74970613 +90.62823631 +90.51717859 +90.41665636 +90.32678131 +90.24765328 +90.17936019 +90.12197791 +90.07557019 +90.0401886 +90.01587244 +90.00264873 +90.00053216 +90.00952508 +90.0296175 +90.06078709 +90.10299924 +90.15620703 +90.22035136 +90.29536095 +90.38115249 +90.47763064 +90.58468822 +90.70220629 +90.83005429 +90.96809017 +91.11616057 +91.274101 +91.44173597 +91.61887924 +91.80533401 +92.00089312 +92.2053393 +92.41844542 +92.6399747 +92.86968104 +93.10730921 +93.35259522 +93.60526656 +93.86504249 +94.13163442 +94.40474614 +94.68407424 +94.96930838 +95.26013166 +95.55622096 +95.85724735 +96.16287637 +96.47276846 +96.78657933 +97.10396035 +97.42455888 +97.74801876 +98.0739806 +98.40208226 +98.73195923 +99.063245 +99.39557151 +99.72856955 +100.0618691 +100.3951 +100.7278919 +101.0598751 +101.3906808 diff --git a/Code_Python/sine_slow_noise.csv b/Code_Python/sine_slow_noise.csv new file mode 100644 index 0000000..04bee1f --- /dev/null +++ b/Code_Python/sine_slow_noise.csv @@ -0,0 +1,500 @@ +115.5672342 +101.3357809 +101.6724076 +113.7876408 +95.68910046 +108.8854032 +104.4579998 +83.7184095 +105.1376931 +103.3840573 +97.108047 +102.8863194 +91.80224238 +107.8733355 +100.0570623 +84.77812113 +104.2708433 +83.58915888 +119.2028286 +91.36226567 +103.5615001 +107.6779544 +94.76216627 +100.0407076 +98.59099393 +98.97322064 +89.03294327 +96.61044071 +101.9896298 +109.0401123 +110.352971 +104.1915472 +117.1589045 +97.90848846 +85.20625064 +92.69288295 +100.2260665 +100.1566312 +80.02766644 +91.42814089 +89.3864446 +88.9677123 +108.4958817 +94.18647487 +94.96847674 +77.22443059 +97.89079577 +83.87671394 +88.35074546 +98.77394575 +81.99414957 +83.64615794 +71.43748108 +89.16806585 +78.70996228 +99.22607491 +96.09085418 +105.6424002 +88.22616544 +86.34174213 +95.34869802 +93.71763483 +106.1807007 +83.92146704 +108.3799273 +88.06765169 +77.6132481 +83.73888411 +94.14809038 +87.01159366 +99.624985 +105.3576787 +85.83087919 +90.18409924 +72.30046881 +100.1933841 +98.31605299 +90.49155266 +96.62514348 +95.15200808 +94.15575222 +95.58012899 +101.6875235 +101.115882 +70.37226926 +72.90624072 +86.60314889 +97.59436959 +94.97845285 +98.98201763 +80.16347967 +83.20359805 +102.0810666 +85.19007105 +91.29049014 +95.0957678 +89.50163019 +91.17021425 +97.8800246 +75.52607134 +92.57844899 +106.1497789 +96.41411921 +92.36485672 +89.51422721 +104.7838475 +96.17725716 +90.01678633 +82.28560782 +96.74762492 +89.87980463 +102.9524253 +91.49356528 +88.47786854 +91.89953738 +92.05679454 +103.5521627 +104.9122446 +114.7613801 +87.09679678 +108.9969937 +97.64873656 +92.90714047 +99.90629576 +90.47980483 +95.68336412 +92.59225994 +109.7754145 +99.40222421 +117.9788645 +102.697881 +124.4631449 +92.88725376 +105.6340206 +98.15966424 +95.83107285 +105.6690485 +102.9762599 +104.4605389 +102.4323003 +108.6613406 +112.4860409 +101.3532559 +105.8401355 +124.8188451 +117.4719577 +114.0244769 +114.093192 +108.6186442 +117.267081 +109.8336009 +98.10280839 +108.2027746 +107.8761995 +108.6823563 +106.5287627 +117.1288934 +112.7673049 +107.2468872 +102.2892507 +106.3075369 +108.8614441 +96.3907438 +107.4083301 +122.8648027 +113.1388697 +116.0475937 +91.53295838 +114.0964309 +125.5864009 +123.4359527 +95.15809582 +114.3160099 +97.68391886 +114.2807207 +102.5933287 +123.757588 +114.7106846 +98.47571736 +114.3772897 +109.9982995 +88.58266139 +120.7402025 +101.9404413 +95.56595759 +114.6557442 +114.9659106 +107.4394786 +116.9104855 +101.2319698 +105.739113 +102.558704 +106.3714351 +93.32603438 +107.9719309 +113.4009992 +100.8891301 +121.2213373 +118.3015657 +116.9197236 +98.27747503 +109.7579138 +101.702454 +111.8144713 +94.45877862 +90.85046529 +111.7009087 +85.08914066 +104.9564443 +119.6430234 +79.82081659 +85.02040582 +100.6112569 +99.66734661 +94.28496216 +91.14047473 +102.4678132 +100.7167911 +108.9990478 +97.52459899 +88.60344384 +87.75681553 +82.11521886 +105.6632777 +86.63615451 +99.87026798 +90.38661165 +101.485997 +104.0821776 +96.0130618 +91.51229294 +102.1454517 +102.6591517 +83.90991997 +77.36318964 +87.21548837 +80.84724051 +101.5107836 +92.56915106 +82.69476282 +80.99644386 +96.46216773 +98.11848977 +96.07287469 +91.64962756 +66.33764057 +79.197356 +100.2617574 +78.81026006 +83.41548111 +99.93882935 +108.0824634 +91.217859 +90.37984683 +79.6301169 +90.36841859 +87.76541977 +92.01372667 +86.45720893 +88.59646597 +84.81470254 +107.7788264 +91.67119408 +92.77506032 +87.55260617 +89.11347241 +81.43556855 +86.38092042 +85.66987323 +109.7118734 +91.1040111 +83.88190076 +85.55381268 +91.4193938 +101.3131808 +81.43745522 +87.31455329 +90.33755891 +99.81151408 +106.684402 +97.70792837 +93.76621469 +91.69048182 +97.18574254 +92.30079581 +89.26458924 +97.42861582 +102.4719797 +108.3840771 +97.10767146 +103.4646264 +99.28298634 +88.67955167 +102.6768356 +98.92729137 +94.12663864 +87.3663415 +87.19902769 +87.41923358 +79.90165728 +83.27061178 +97.92832444 +96.51270856 +86.29228515 +97.04999131 +87.61700054 +102.3950804 +109.8183084 +89.72060962 +106.2124507 +104.3946814 +97.23175775 +113.5856281 +96.03594247 +89.14733326 +104.703616 +121.5732584 +99.93797428 +114.3042129 +78.84954727 +103.2281991 +128.2015951 +94.42699371 +103.9150872 +81.92716427 +100.1234421 +100.2498074 +138.3697542 +100.4779671 +112.6106694 +118.3492065 +93.42376516 +93.9574748 +91.68938826 +85.91829157 +102.7823054 +108.8603989 +99.29350704 +105.4119148 +104.8475803 +118.2392459 +114.9315706 +104.5023825 +115.2774196 +93.6488869 +111.6894641 +115.7819675 +98.39662966 +104.1481387 +117.2605802 +126.7892667 +106.9216245 +108.9963278 +122.4931013 +94.24926393 +104.4753435 +120.2328613 +101.1800659 +115.8940486 +95.36951165 +104.3855795 +118.1921456 +110.6871452 +116.0912641 +114.7747094 +125.2496692 +106.7349761 +115.4219948 +114.3395831 +105.917662 +119.364546 +112.6979065 +96.20257895 +107.6177896 +105.9358521 +115.8610687 +99.20501345 +87.68995605 +123.1897901 +98.02895782 +95.48723167 +98.35491481 +92.57220462 +118.5306661 +99.24077403 +112.9958766 +111.3604642 +112.3225746 +74.85394314 +106.244066 +97.04028992 +96.98762067 +106.0505782 +103.6805113 +95.46956312 +92.91983893 +102.6308354 +90.32892705 +95.73816035 +103.2442121 +111.7224927 +109.4991855 +88.00131205 +87.6079082 +112.3614284 +99.97522782 +80.22998372 +85.96033451 +85.40340913 +102.8643718 +106.9974557 +96.14400112 +90.63832437 +108.8355253 +104.3734085 +92.147686 +96.39533626 +111.2250368 +81.65078792 +99.81066025 +98.01276717 +78.07720187 +85.8005895 +99.30102938 +87.2291675 +85.05404714 +99.99921664 +105.1660088 +86.63556105 +99.86613219 +93.77406649 +104.6050015 +90.43610971 +107.7273762 +96.01179742 +112.8139616 +94.65978303 +87.56220328 +85.12668017 +90.07825587 +81.64916045 +89.00651045 +93.38843 +89.3393326 +108.8127612 +79.78539833 +79.33010316 +84.40458774 +74.22738983 +95.13661005 +88.4526456 +80.6699032 +96.01623242 +104.8575109 +83.05433277 +94.47077054 +95.42820344 +83.45761942 +77.16736072 +108.7108433 +88.2118547 +89.09641098 +84.22192739 +96.70630031 +103.73901 +95.14031225 +77.62110462 +89.47014925 +97.66069651 +98.51061704 +105.1499812 +96.00169182 +103.0872119 +86.4214719 +94.98891096 +105.3251198 +84.07151501 +90.96977702 +84.47679852 +87.56417784 +71.36401469 +93.52952914 +85.30760156 +106.4928465 +109.1869557 +95.51556128 +95.57814343 +106.6067326 +103.8086802 +78.22465239 +90.84343693 +102.6572335 +93.37748269 +93.00855817 +133.3098287 +92.02010694 +99.0918937 +89.4371333 +99.32065336 +84.99652824 diff --git a/Code_Python/spx.csv b/Code_Python/spx.csv new file mode 100644 index 0000000..4e70684 --- /dev/null +++ b/Code_Python/spx.csv @@ -0,0 +1,500 @@ +1399.48 +1410.49 +1409.3 +1410.44 +1411.13 +1402.08 +1413.49 +1413.17 +1418.13 +1418.16 +1415.51 +1405.53 +1403.93 +1404.11 +1405.87 +1402.8 +1402.22 +1401.35 +1394.23 +1390.99 +1365 +1375.32 +1379.32 +1385.3 +1385.97 +1360.02 +1337.89 +1338.31 +1350.52 +1362.66 +1376.51 +1372.78 +1363.67 +1353.64 +1356.78 +1334.76 +1341.45 +1341.47 +1352.46 +1354.68 +1367.58 +1374.02 +1365.51 +1362.16 +1329.04 +1331.85 +1319.99 +1313.72 +1335.02 +1325.51 +1355.69 +1357.98 +1344.78 +1342.84 +1329.1 +1314.88 +1324.18 +1308.93 +1325.66 +1314.99 +1315.13 +1285.5 +1278.18 +1278.04 +1310.33 +1313.32 +1332.42 +1317.82 +1320.68 +1318.86 +1316.63 +1315.99 +1295.22 +1304.86 +1324.8 +1330.66 +1338.35 +1353.39 +1357.99 +1354.58 +1363.72 +1369.58 +1369.1 +1391.57 +1402.31 +1405.82 +1397.91 +1403.36 +1399.98 +1390.69 +1371.97 +1366.94 +1378.53 +1376.92 +1385.14 +1390.78 +1369.57 +1370.26 +1387.57 +1368.71 +1358.59 +1382.2 +1398.08 +1398.96 +1413.38 +1419.04 +1408.47 +1403.28 +1405.54 +1412.52 +1416.51 +1397.11 +1392.78 +1402.89 +1405.52 +1409.75 +1404.17 +1402.6 +1394.28 +1395.95 +1371.09 +1370.87 +1365.91 +1352.63 +1343.36 +1364.33 +1369.63 +1374.09 +1365.68 +1372.18 +1367.59 +1365.74 +1363.46 +1357.66 +1362.21 +1361.23 +1358.04 +1343.23 +1350.5 +1351.77 +1342.64 +1351.95 +1349.96 +1347.05 +1344.33 +1344.9 +1325.54 +1324.09 +1312.41 +1313.01 +1316.33 +1318.43 +1326.06 +1314.65 +1316 +1315.38 +1314.5 +1308.04 +1293.67 +1289.09 +1295.5 +1292.48 +1292.08 +1280.7 +1277.81 +1281.06 +1277.3 +1277.06 +1257.6 +1263.02 +1249.64 +1265.43 +1265.33 +1254 +1243.72 +1241.3 +1205.35 +1219.66 +1215.75 +1211.82 +1225.73 +1236.47 +1255.19 +1234.35 +1261.01 +1258.47 +1257.08 +1244.28 +1244.58 +1246.96 +1195.19 +1192.55 +1158.67 +1161.79 +1188.04 +1192.98 +1215.65 +1216.13 +1236.91 +1257.81 +1251.78 +1263.85 +1239.7 +1229.1 +1275.92 +1261.12 +1253.23 +1261.15 +1237.9 +1218.28 +1253.3 +1285.09 +1284.59 +1242 +1229.05 +1254.19 +1238.25 +1215.39 +1209.88 +1225.38 +1200.86 +1224.58 +1203.66 +1207.25 +1195.54 +1194.89 +1155.46 +1164.97 +1144.03 +1123.95 +1099.23 +1131.42 +1160.4 +1151.06 +1175.38 +1162.95 +1136.43 +1129.56 +1166.76 +1202.09 +1204.09 +1216.01 +1209.11 +1188.68 +1172.87 +1162.27 +1154.23 +1185.9 +1198.62 +1165.24 +1173.97 +1204.42 +1218.89 +1212.92 +1210.08 +1176.8 +1159.27 +1177.6 +1162.35 +1123.82 +1123.53 +1140.65 +1193.89 +1192.76 +1204.49 +1178.81 +1172.64 +1120.76 +1172.53 +1119.46 +1199.38 +1200.07 +1260.34 +1254.05 +1286.94 +1292.28 +1300.67 +1304.89 +1331.94 +1337.43 +1345.02 +1343.8 +1325.84 +1326.73 +1305.44 +1316.14 +1308.87 +1317.72 +1313.64 +1319.49 +1343.8 +1353.22 +1339.22 +1337.88 +1339.67 +1320.64 +1307.41 +1296.67 +1280.1 +1268.45 +1283.5 +1287.14 +1295.52 +1278.36 +1271.5 +1267.64 +1265.42 +1287.87 +1271.83 +1270.98 +1289 +1279.56 +1284.94 +1286.17 +1300.16 +1312.94 +1314.55 +1345.2 +1331.1 +1325.69 +1320.47 +1316.28 +1317.37 +1333.27 +1343.6 +1340.68 +1328.98 +1329.47 +1337.77 +1348.65 +1342.08 +1357.16 +1346.29 +1340.2 +1335.1 +1347.32 +1356.62 +1361.22 +1363.61 +1360.48 +1355.66 +1347.24 +1335.25 +1337.38 +1330.36 +1312.62 +1305.14 +1319.68 +1314.52 +1314.41 +1314.16 +1324.46 +1328.17 +1333.51 +1335.54 +1332.63 +1332.87 +1332.41 +1325.83 +1328.26 +1319.44 +1310.19 +1313.8 +1309.66 +1297.54 +1293.77 +1298.38 +1279.2 +1273.72 +1256.88 +1281.87 +1296.39 +1304.28 +1295.11 +1320.02 +1321.82 +1310.13 +1321.15 +1330.97 +1308.44 +1306.33 +1327.22 +1319.88 +1306.1 +1307.4 +1315.44 +1343.01 +1340.43 +1336.32 +1328.01 +1332.32 +1329.15 +1321.87 +1320.88 +1324.57 +1319.05 +1310.87 +1307.1 +1304.03 +1307.59 +1286.12 +1276.34 +1299.54 +1296.63 +1291.18 +1290.84 +1283.35 +1280.26 +1281.92 +1295.02 +1293.24 +1283.76 +1285.96 +1274.48 +1269.75 +1271.5 +1273.85 +1276.56 +1270.2 +1271.89 +1257.64 +1257.88 +1259.78 +1258.51 +1257.54 +1256.77 +1258.84 +1254.6 +1247.08 +1243.91 +1242.87 +1235.23 +1241.59 +1240.46 +1240.4 +1233 +1228.28 +1223.75 +1223.12 +1224.71 +1221.53 +1206.07 +1180.55 +1187.76 +1189.4 +1198.35 +1180.73 +1197.84 +1199.73 +1196.69 +1178.59 +1178.34 +1197.75 +1199.21 +1213.54 +1218.71 +1213.4 +1223.25 +1225.85 +1221.06 +1197.96 +1193.57 +1184.38 +1183.26 +1183.78 +1182.45 +1185.64 +1185.62 +1183.08 +1180.26 +1178.17 +1165.9 +1184.71 +1176.19 +1173.81 +1178.1 +1169.77 +1165.32 +1165.15 +1158.06 +1159.97 +1160.75 +1137.03 +1146.24 +1141.2 +1144.73 +1147.7 +1142.16 +1148.67 +1124.83 +1134.28 +1139.78 +1142.71 +1125.59 +1124.66 +1125.07 +1121.1 +1121.9 +1109.55 +1104.18 diff --git a/Code_Python/spx3.csv b/Code_Python/spx3.csv new file mode 100644 index 0000000..ed0bd7b --- /dev/null +++ b/Code_Python/spx3.csv @@ -0,0 +1,500 @@ +1399.48,1399.48,1399.48 +1410.49,1410.49,1410.49 +1409.3,1409.3,1409.3 +1410.44,1410.44,1410.44 +1411.13,1411.13,1411.13 +1402.08,1402.08,1402.08 +1413.49,1413.49,1413.49 +1413.17,1413.17,1413.17 +1418.13,1418.13,1418.13 +1418.16,1418.16,1418.16 +1415.51,1415.51,1415.51 +1405.53,1405.53,1405.53 +1403.93,1403.93,1403.93 +1404.11,1404.11,1404.11 +1405.87,1405.87,1405.87 +1402.8,1402.8,1402.8 +1402.22,1402.22,1402.22 +1401.35,1401.35,1401.35 +1394.23,1394.23,1394.23 +1390.99,1390.99,1390.99 +1365,1365,1365 +1375.32,1375.32,1375.32 +1379.32,1379.32,1379.32 +1385.3,1385.3,1385.3 +1385.97,1385.97,1385.97 +1360.02,1360.02,1360.02 +1337.89,1337.89,1337.89 +1338.31,1338.31,1338.31 +1350.52,1350.52,1350.52 +1362.66,1362.66,1362.66 +1376.51,1376.51,1376.51 +1372.78,1372.78,1372.78 +1363.67,1363.67,1363.67 +1353.64,1353.64,1353.64 +1356.78,1356.78,1356.78 +1334.76,1334.76,1334.76 +1341.45,1341.45,1341.45 +1341.47,1341.47,1341.47 +1352.46,1352.46,1352.46 +1354.68,1354.68,1354.68 +1367.58,1367.58,1367.58 +1374.02,1374.02,1374.02 +1365.51,1365.51,1365.51 +1362.16,1362.16,1362.16 +1329.04,1329.04,1329.04 +1331.85,1331.85,1331.85 +1319.99,1319.99,1319.99 +1313.72,1313.72,1313.72 +1335.02,1335.02,1335.02 +1325.51,1325.51,1325.51 +1355.69,1355.69,1355.69 +1357.98,1357.98,1357.98 +1344.78,1344.78,1344.78 +1342.84,1342.84,1342.84 +1329.1,1329.1,1329.1 +1314.88,1314.88,1314.88 +1324.18,1324.18,1324.18 +1308.93,1308.93,1308.93 +1325.66,1325.66,1325.66 +1314.99,1314.99,1314.99 +1315.13,1315.13,1315.13 +1285.5,1285.5,1285.5 +1278.18,1278.18,1278.18 +1278.04,1278.04,1278.04 +1310.33,1310.33,1310.33 +1313.32,1313.32,1313.32 +1332.42,1332.42,1332.42 +1317.82,1317.82,1317.82 +1320.68,1320.68,1320.68 +1318.86,1318.86,1318.86 +1316.63,1316.63,1316.63 +1315.99,1315.99,1315.99 +1295.22,1295.22,1295.22 +1304.86,1304.86,1304.86 +1324.8,1324.8,1324.8 +1330.66,1330.66,1330.66 +1338.35,1338.35,1338.35 +1353.39,1353.39,1353.39 +1357.99,1357.99,1357.99 +1354.58,1354.58,1354.58 +1363.72,1363.72,1363.72 +1369.58,1369.58,1369.58 +1369.1,1369.1,1369.1 +1391.57,1391.57,1391.57 +1402.31,1402.31,1402.31 +1405.82,1405.82,1405.82 +1397.91,1397.91,1397.91 +1403.36,1403.36,1403.36 +1399.98,1399.98,1399.98 +1390.69,1390.69,1390.69 +1371.97,1371.97,1371.97 +1366.94,1366.94,1366.94 +1378.53,1378.53,1378.53 +1376.92,1376.92,1376.92 +1385.14,1385.14,1385.14 +1390.78,1390.78,1390.78 +1369.57,1369.57,1369.57 +1370.26,1370.26,1370.26 +1387.57,1387.57,1387.57 +1368.71,1368.71,1368.71 +1358.59,1358.59,1358.59 +1382.2,1382.2,1382.2 +1398.08,1398.08,1398.08 +1398.96,1398.96,1398.96 +1413.38,1413.38,1413.38 +1419.04,1419.04,1419.04 +1408.47,1408.47,1408.47 +1403.28,1403.28,1403.28 +1405.54,1405.54,1405.54 +1412.52,1412.52,1412.52 +1416.51,1416.51,1416.51 +1397.11,1397.11,1397.11 +1392.78,1392.78,1392.78 +1402.89,1402.89,1402.89 +1405.52,1405.52,1405.52 +1409.75,1409.75,1409.75 +1404.17,1404.17,1404.17 +1402.6,1402.6,1402.6 +1394.28,1394.28,1394.28 +1395.95,1395.95,1395.95 +1371.09,1371.09,1371.09 +1370.87,1370.87,1370.87 +1365.91,1365.91,1365.91 +1352.63,1352.63,1352.63 +1343.36,1343.36,1343.36 +1364.33,1364.33,1364.33 +1369.63,1369.63,1369.63 +1374.09,1374.09,1374.09 +1365.68,1365.68,1365.68 +1372.18,1372.18,1372.18 +1367.59,1367.59,1367.59 +1365.74,1365.74,1365.74 +1363.46,1363.46,1363.46 +1357.66,1357.66,1357.66 +1362.21,1362.21,1362.21 +1361.23,1361.23,1361.23 +1358.04,1358.04,1358.04 +1343.23,1343.23,1343.23 +1350.5,1350.5,1350.5 +1351.77,1351.77,1351.77 +1342.64,1342.64,1342.64 +1351.95,1351.95,1351.95 +1349.96,1349.96,1349.96 +1347.05,1347.05,1347.05 +1344.33,1344.33,1344.33 +1344.9,1344.9,1344.9 +1325.54,1325.54,1325.54 +1324.09,1324.09,1324.09 +1312.41,1312.41,1312.41 +1313.01,1313.01,1313.01 +1316.33,1316.33,1316.33 +1318.43,1318.43,1318.43 +1326.06,1326.06,1326.06 +1314.65,1314.65,1314.65 +1316,1316,1316 +1315.38,1315.38,1315.38 +1314.5,1314.5,1314.5 +1308.04,1308.04,1308.04 +1293.67,1293.67,1293.67 +1289.09,1289.09,1289.09 +1295.5,1295.5,1295.5 +1292.48,1292.48,1292.48 +1292.08,1292.08,1292.08 +1280.7,1280.7,1280.7 +1277.81,1277.81,1277.81 +1281.06,1281.06,1281.06 +1277.3,1277.3,1277.3 +1277.06,1277.06,1277.06 +1257.6,1257.6,1257.6 +1263.02,1263.02,1263.02 +1249.64,1249.64,1249.64 +1265.43,1265.43,1265.43 +1265.33,1265.33,1265.33 +1254,1254,1254 +1243.72,1243.72,1243.72 +1241.3,1241.3,1241.3 +1205.35,1205.35,1205.35 +1219.66,1219.66,1219.66 +1215.75,1215.75,1215.75 +1211.82,1211.82,1211.82 +1225.73,1225.73,1225.73 +1236.47,1236.47,1236.47 +1255.19,1255.19,1255.19 +1234.35,1234.35,1234.35 +1261.01,1261.01,1261.01 +1258.47,1258.47,1258.47 +1257.08,1257.08,1257.08 +1244.28,1244.28,1244.28 +1244.58,1244.58,1244.58 +1246.96,1246.96,1246.96 +1195.19,1195.19,1195.19 +1192.55,1192.55,1192.55 +1158.67,1158.67,1158.67 +1161.79,1161.79,1161.79 +1188.04,1188.04,1188.04 +1192.98,1192.98,1192.98 +1215.65,1215.65,1215.65 +1216.13,1216.13,1216.13 +1236.91,1236.91,1236.91 +1257.81,1257.81,1257.81 +1251.78,1251.78,1251.78 +1263.85,1263.85,1263.85 +1239.7,1239.7,1239.7 +1229.1,1229.1,1229.1 +1275.92,1275.92,1275.92 +1261.12,1261.12,1261.12 +1253.23,1253.23,1253.23 +1261.15,1261.15,1261.15 +1237.9,1237.9,1237.9 +1218.28,1218.28,1218.28 +1253.3,1253.3,1253.3 +1285.09,1285.09,1285.09 +1284.59,1284.59,1284.59 +1242,1242,1242 +1229.05,1229.05,1229.05 +1254.19,1254.19,1254.19 +1238.25,1238.25,1238.25 +1215.39,1215.39,1215.39 +1209.88,1209.88,1209.88 +1225.38,1225.38,1225.38 +1200.86,1200.86,1200.86 +1224.58,1224.58,1224.58 +1203.66,1203.66,1203.66 +1207.25,1207.25,1207.25 +1195.54,1195.54,1195.54 +1194.89,1194.89,1194.89 +1155.46,1155.46,1155.46 +1164.97,1164.97,1164.97 +1144.03,1144.03,1144.03 +1123.95,1123.95,1123.95 +1099.23,1099.23,1099.23 +1131.42,1131.42,1131.42 +1160.4,1160.4,1160.4 +1151.06,1151.06,1151.06 +1175.38,1175.38,1175.38 +1162.95,1162.95,1162.95 +1136.43,1136.43,1136.43 +1129.56,1129.56,1129.56 +1166.76,1166.76,1166.76 +1202.09,1202.09,1202.09 +1204.09,1204.09,1204.09 +1216.01,1216.01,1216.01 +1209.11,1209.11,1209.11 +1188.68,1188.68,1188.68 +1172.87,1172.87,1172.87 +1162.27,1162.27,1162.27 +1154.23,1154.23,1154.23 +1185.9,1185.9,1185.9 +1198.62,1198.62,1198.62 +1165.24,1165.24,1165.24 +1173.97,1173.97,1173.97 +1204.42,1204.42,1204.42 +1218.89,1218.89,1218.89 +1212.92,1212.92,1212.92 +1210.08,1210.08,1210.08 +1176.8,1176.8,1176.8 +1159.27,1159.27,1159.27 +1177.6,1177.6,1177.6 +1162.35,1162.35,1162.35 +1123.82,1123.82,1123.82 +1123.53,1123.53,1123.53 +1140.65,1140.65,1140.65 +1193.89,1193.89,1193.89 +1192.76,1192.76,1192.76 +1204.49,1204.49,1204.49 +1178.81,1178.81,1178.81 +1172.64,1172.64,1172.64 +1120.76,1120.76,1120.76 +1172.53,1172.53,1172.53 +1119.46,1119.46,1119.46 +1199.38,1199.38,1199.38 +1200.07,1200.07,1200.07 +1260.34,1260.34,1260.34 +1254.05,1254.05,1254.05 +1286.94,1286.94,1286.94 +1292.28,1292.28,1292.28 +1300.67,1300.67,1300.67 +1304.89,1304.89,1304.89 +1331.94,1331.94,1331.94 +1337.43,1337.43,1337.43 +1345.02,1345.02,1345.02 +1343.8,1343.8,1343.8 +1325.84,1325.84,1325.84 +1326.73,1326.73,1326.73 +1305.44,1305.44,1305.44 +1316.14,1316.14,1316.14 +1308.87,1308.87,1308.87 +1317.72,1317.72,1317.72 +1313.64,1313.64,1313.64 +1319.49,1319.49,1319.49 +1343.8,1343.8,1343.8 +1353.22,1353.22,1353.22 +1339.22,1339.22,1339.22 +1337.88,1337.88,1337.88 +1339.67,1339.67,1339.67 +1320.64,1320.64,1320.64 +1307.41,1307.41,1307.41 +1296.67,1296.67,1296.67 +1280.1,1280.1,1280.1 +1268.45,1268.45,1268.45 +1283.5,1283.5,1283.5 +1287.14,1287.14,1287.14 +1295.52,1295.52,1295.52 +1278.36,1278.36,1278.36 +1271.5,1271.5,1271.5 +1267.64,1267.64,1267.64 +1265.42,1265.42,1265.42 +1287.87,1287.87,1287.87 +1271.83,1271.83,1271.83 +1270.98,1270.98,1270.98 +1289,1289,1289 +1279.56,1279.56,1279.56 +1284.94,1284.94,1284.94 +1286.17,1286.17,1286.17 +1300.16,1300.16,1300.16 +1312.94,1312.94,1312.94 +1314.55,1314.55,1314.55 +1345.2,1345.2,1345.2 +1331.1,1331.1,1331.1 +1325.69,1325.69,1325.69 +1320.47,1320.47,1320.47 +1316.28,1316.28,1316.28 +1317.37,1317.37,1317.37 +1333.27,1333.27,1333.27 +1343.6,1343.6,1343.6 +1340.68,1340.68,1340.68 +1328.98,1328.98,1328.98 +1329.47,1329.47,1329.47 +1337.77,1337.77,1337.77 +1348.65,1348.65,1348.65 +1342.08,1342.08,1342.08 +1357.16,1357.16,1357.16 +1346.29,1346.29,1346.29 +1340.2,1340.2,1340.2 +1335.1,1335.1,1335.1 +1347.32,1347.32,1347.32 +1356.62,1356.62,1356.62 +1361.22,1361.22,1361.22 +1363.61,1363.61,1363.61 +1360.48,1360.48,1360.48 +1355.66,1355.66,1355.66 +1347.24,1347.24,1347.24 +1335.25,1335.25,1335.25 +1337.38,1337.38,1337.38 +1330.36,1330.36,1330.36 +1312.62,1312.62,1312.62 +1305.14,1305.14,1305.14 +1319.68,1319.68,1319.68 +1314.52,1314.52,1314.52 +1314.41,1314.41,1314.41 +1314.16,1314.16,1314.16 +1324.46,1324.46,1324.46 +1328.17,1328.17,1328.17 +1333.51,1333.51,1333.51 +1335.54,1335.54,1335.54 +1332.63,1332.63,1332.63 +1332.87,1332.87,1332.87 +1332.41,1332.41,1332.41 +1325.83,1325.83,1325.83 +1328.26,1328.26,1328.26 +1319.44,1319.44,1319.44 +1310.19,1310.19,1310.19 +1313.8,1313.8,1313.8 +1309.66,1309.66,1309.66 +1297.54,1297.54,1297.54 +1293.77,1293.77,1293.77 +1298.38,1298.38,1298.38 +1279.2,1279.2,1279.2 +1273.72,1273.72,1273.72 +1256.88,1256.88,1256.88 +1281.87,1281.87,1281.87 +1296.39,1296.39,1296.39 +1304.28,1304.28,1304.28 +1295.11,1295.11,1295.11 +1320.02,1320.02,1320.02 +1321.82,1321.82,1321.82 +1310.13,1310.13,1310.13 +1321.15,1321.15,1321.15 +1330.97,1330.97,1330.97 +1308.44,1308.44,1308.44 +1306.33,1306.33,1306.33 +1327.22,1327.22,1327.22 +1319.88,1319.88,1319.88 +1306.1,1306.1,1306.1 +1307.4,1307.4,1307.4 +1315.44,1315.44,1315.44 +1343.01,1343.01,1343.01 +1340.43,1340.43,1340.43 +1336.32,1336.32,1336.32 +1328.01,1328.01,1328.01 +1332.32,1332.32,1332.32 +1329.15,1329.15,1329.15 +1321.87,1321.87,1321.87 +1320.88,1320.88,1320.88 +1324.57,1324.57,1324.57 +1319.05,1319.05,1319.05 +1310.87,1310.87,1310.87 +1307.1,1307.1,1307.1 +1304.03,1304.03,1304.03 +1307.59,1307.59,1307.59 +1286.12,1286.12,1286.12 +1276.34,1276.34,1276.34 +1299.54,1299.54,1299.54 +1296.63,1296.63,1296.63 +1291.18,1291.18,1291.18 +1290.84,1290.84,1290.84 +1283.35,1283.35,1283.35 +1280.26,1280.26,1280.26 +1281.92,1281.92,1281.92 +1295.02,1295.02,1295.02 +1293.24,1293.24,1293.24 +1283.76,1283.76,1283.76 +1285.96,1285.96,1285.96 +1274.48,1274.48,1274.48 +1269.75,1269.75,1269.75 +1271.5,1271.5,1271.5 +1273.85,1273.85,1273.85 +1276.56,1276.56,1276.56 +1270.2,1270.2,1270.2 +1271.89,1271.89,1271.89 +1257.64,1257.64,1257.64 +1257.88,1257.88,1257.88 +1259.78,1259.78,1259.78 +1258.51,1258.51,1258.51 +1257.54,1257.54,1257.54 +1256.77,1256.77,1256.77 +1258.84,1258.84,1258.84 +1254.6,1254.6,1254.6 +1247.08,1247.08,1247.08 +1243.91,1243.91,1243.91 +1242.87,1242.87,1242.87 +1235.23,1235.23,1235.23 +1241.59,1241.59,1241.59 +1240.46,1240.46,1240.46 +1240.4,1240.4,1240.4 +1233,1233,1233 +1228.28,1228.28,1228.28 +1223.75,1223.75,1223.75 +1223.12,1223.12,1223.12 +1224.71,1224.71,1224.71 +1221.53,1221.53,1221.53 +1206.07,1206.07,1206.07 +1180.55,1180.55,1180.55 +1187.76,1187.76,1187.76 +1189.4,1189.4,1189.4 +1198.35,1198.35,1198.35 +1180.73,1180.73,1180.73 +1197.84,1197.84,1197.84 +1199.73,1199.73,1199.73 +1196.69,1196.69,1196.69 +1178.59,1178.59,1178.59 +1178.34,1178.34,1178.34 +1197.75,1197.75,1197.75 +1199.21,1199.21,1199.21 +1213.54,1213.54,1213.54 +1218.71,1218.71,1218.71 +1213.4,1213.4,1213.4 +1223.25,1223.25,1223.25 +1225.85,1225.85,1225.85 +1221.06,1221.06,1221.06 +1197.96,1197.96,1197.96 +1193.57,1193.57,1193.57 +1184.38,1184.38,1184.38 +1183.26,1183.26,1183.26 +1183.78,1183.78,1183.78 +1182.45,1182.45,1182.45 +1185.64,1185.64,1185.64 +1185.62,1185.62,1185.62 +1183.08,1183.08,1183.08 +1180.26,1180.26,1180.26 +1178.17,1178.17,1178.17 +1165.9,1165.9,1165.9 +1184.71,1184.71,1184.71 +1176.19,1176.19,1176.19 +1173.81,1173.81,1173.81 +1178.1,1178.1,1178.1 +1169.77,1169.77,1169.77 +1165.32,1165.32,1165.32 +1165.15,1165.15,1165.15 +1158.06,1158.06,1158.06 +1159.97,1159.97,1159.97 +1160.75,1160.75,1160.75 +1137.03,1137.03,1137.03 +1146.24,1146.24,1146.24 +1141.2,1141.2,1141.2 +1144.73,1144.73,1144.73 +1147.7,1147.7,1147.7 +1142.16,1142.16,1142.16 +1148.67,1148.67,1148.67 +1124.83,1124.83,1124.83 +1134.28,1134.28,1134.28 +1139.78,1139.78,1139.78 +1142.71,1142.71,1142.71 +1125.59,1125.59,1125.59 +1124.66,1124.66,1124.66 +1125.07,1125.07,1125.07 +1121.1,1121.1,1121.1 +1121.9,1121.9,1121.9 +1109.55,1109.55,1109.55 +1104.18,1104.18,1104.18 diff --git a/Code_Python/test.py b/Code_Python/test.py new file mode 100644 index 0000000..0793c0c --- /dev/null +++ b/Code_Python/test.py @@ -0,0 +1,37 @@ +""" +Filters for time series. + +Copyright (c) 2020 Gabriele Gilardi + + + +ToDo: +- use NaN/input values for points not filtered? +- what to use as previous Y in recursive filters? i.e. set Y=X or set Y=0? +- plot filtered data (utils, with generic number of arguments passed) +- plot filter characteristics (utils) +- return idx? +- util to test filter (impulse, utils) +""" + +import sys +import numpy as np +import filters as flt +import utils as utl + +# Read data to filter +if len(sys.argv) != 2: + print("Usage: python test.py ") + sys.exit(1) +data_file = sys.argv[1] + '.csv' + +# Read data from a csv file +data = np.loadtxt(data_file, delimiter=',') +n_samples = data.shape[0] +data = data.reshape(n_samples, -1) + +spx = flt.Filter(data) +EMA = spx.EMA() +print(EMA[0:5,:]) +# args = (spx.X, spx.SMA(N=5), spx.EMA(alpha=0.7)) +# utl.plot_signals(args) \ No newline at end of file diff --git a/Code_Python/utils.py b/Code_Python/utils.py new file mode 100644 index 0000000..cfae932 --- /dev/null +++ b/Code_Python/utils.py @@ -0,0 +1,119 @@ +""" +Utility functions for ????. + +Copyright (c) 2020 Gabriele Gilardi +""" + +import numpy as np +import matplotlib.pyplot as plt + + +def normalize_data(X, param=(), ddof=0): + """ + If mu and sigma are not defined, returns a column-normalized version of + X with zero mean and standard deviation equal to one. If mu and sigma are + defined returns a column-normalized version of X using mu and sigma. + + X Input dataset + Xn Column-normalized input dataset + param Tuple with mu and sigma + mu Mean + sigma Standard deviation + ddof Delta degrees of freedom (if ddof = 0 then divide by m, if + ddof = 1 then divide by m-1, with m the number of data in X) + """ + # Column-normalize using mu and sigma + if (len(param) > 0): + Xn = (X - param[0]) / param[1] + return Xn + + # Column-normalize using mu=0 and sigma=1 + else: + mu = X.mean(axis=0) + sigma = X.std(axis=0, ddof=ddof) + Xn = (X - mu) / sigma + param = (mu, sigma) + return Xn, param + + +def scale_data(X, param=()): + """ + If X_min and X_max are not defined, returns a column-scaled version of + X in the interval (-1,+1). If X_min and X_max are defined returns a + column-scaled version of X using X_min and X_max. + + X Input dataset + Xs Column-scaled input dataset + param Tuple with X_min and X_max + X_min Min. value along the columns (features) of the input dataset + X_max Max. value along the columns (features) of the input dataset + """ + # Column-scale using X_min and X_max + if (len(param) > 0): + Xs = -1.0 + 2.0 * (X - param[0]) / (param[1] - param[0]) + return Xs + + # Column-scale using X_min=-1 and X_max=+1 + else: + X_min = np.amin(X, axis=0) + X_max = np.amax(X, axis=0) + Xs = -1.0 + 2.0 * (X - X_min) / (X_max - X_min) + param = (X_min, X_max) + return Xs, param + + +def calc_rmse(a, b): + """ + Calculates the root-mean-square-error of arrays and . If the arrays + are multi-column, the RMSE is calculated as all the columns are one single + vector. + """ + # Convert to (n, ) dimension + a = a.flatten() + b = b.flatten() + + # Root-mean-square-error + rmse = np.sqrt(((a - b) ** 2).sum() / len(a)) + + return rmse + + +def calc_corr(a, b): + """ + Calculates the correlation between arrays and . If the arrays are + multi-column, the correlation is calculated as all the columns are one + single vector. + """ + # Convert to (n, ) dimension + a = a.flatten() + b = b.flatten() + + # Correlation + corr = np.corrcoef(a, b)[0, 1] + + return corr + + +def calc_accu(a, b): + """ + Calculates the accuracy (in %) between arrays and . The two arrays + must be column/row vectors. + """ + # Convert to (n, ) dimension + a = a.flatten() + b = b.flatten() + + # Correlation + accu = 100.0 * (a == b).sum() / len(a) + + return accu + + +def plot_signals(signals): + """ + """ + for signal in signals: + plt.plot(signal) + + plt.grid(b=True) + plt.show() diff --git a/README.md b/README.md index eb95de1..34eb85e 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,10 @@ ## Reference +- [1] John F. Ehlers, "[Cycle Analytics for Traders: Advanced Technical Trading Concepts](http://www.mesasoftware.com/ehlers_books.htm)". + +- [2] John F. Ehlers, "[Signal Analysis, Filters And Trading Strategies](http://www.mesasoftware.com/ehlers_technical_papers.htm)". + ## Characteristics ## Parameters