import numpy as np
import pylab as plt
from numpy import fft
import src.mylib.mlstm as mlstm

ds = mlstm.loadFXData('JPY=X', '../db/forex.db', 1024)
x = ds[['Close']].values
x = x.flatten()
#t = np.arange(256)
#x = np.sin(t)

n = x.size
spectrum = fft.fft(x)
feq = fft.fftfreq(n)            # frequencies

ampli = np.absolute(spectrum)   # amplitude
phase = np.angle(spectrum)      # phase
print(phase)

plt.plot(ampli)
plt.legend()
plt.show()

@@ -87,16 +87,204 @@
  mlstm%0A%0A
+def bandpass_filter(x, freq, frequency_of_signal=0, band=0.1):%0A    if (frequency_of_signal - band) %3C abs(freq) %3C (frequency_of_signal + band):%0A        return x%0A    else:%0A        return 0%0A%0A
 ds = mls
@@ -328,12 +328,12 @@
 b', 
-1024
+9000
 )%0Ax 
@@ -375,55 +375,70 @@
 n()%0A
-#t = np.arange(256)%0A#x = np.sin(t)%0A%0An = x.size%0A
+L = %5B%5D%0Afor i in range(1000):%0A    x = x%5Bi:%5D%0A    N = len(x)%0A    
 spec
@@ -455,16 +455,20 @@
 .fft(x)%0A
+    
 feq = ff
@@ -477,17 +477,17 @@
 fftfreq(
-n
+N
 )       
@@ -505,17 +505,20 @@
 uencies%0A
-%0A
+    
 ampli = 
@@ -553,16 +553,20 @@
 plitude%0A
+    
 phase = 
@@ -597,16 +597,21 @@
 # phase%0A
+    #
 print(ph
@@ -619,23 +619,438 @@
 se)%0A
-%0Aplt.plot(ampli
+    index = np.argsort(-ampli)%0A    sfreq = feq%5Bindex%5D%0A    sampl = ampli%5Bindex%5D%0A    #sfreq = np.where(sfreq %3E 0)%0A    #big = list(zip(*sfreq))%0A    print(sfreq%5B1:10%5D * N)%0A    #plt.semilogy(sfreq * N, sampl, 'o')%0A#F_filtered = np.asanyarray(%5Bbandpass_filter(x, freq) for x, freq in zip(spectrum, feq)%5D)%0A#filtered_signal = np.fft.ifft(F_filtered)%0A%0A#plt.semilogy(feq%5B1:%5D, ampli%5B1:%5D), 'o') #zero feq is very large%0A#plt.semilogy(ampli%5B1:%5D
 )%0Apl

Add Tensor Flow