Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Creation_donnee.py 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Tue Oct 26 17:53:54 2021
  4. @author: virgi
  5. """
  6. import numpy as np
  7. import math as ma
  8. len_seq = 10
  9. def creation_sin_RNN(len_seq,tmin,tmax,n,w,a=1,b=0):
  10. Datax, Datay = [], []
  11. t = np.linspace(tmin,tmax,n)
  12. x =a* np.sin(2*ma.pi*w*t)+b
  13. for i in range(len(x)-len_seq):
  14. Datax.append([x[i:i+len_seq]])
  15. Datay.append([x[i+1:i+len_seq+1]])
  16. Datax = np.array(Datax)
  17. Datay = np.array(Datay)
  18. return(Datax,Datay)
  19. def creation_x_sin_RNN(len_seq,tmin,tmax,n,w,a=1,b=1,c=0):
  20. Datax, Datay = [], []
  21. t = np.linspace(tmin,tmax,n)
  22. x=[]
  23. for i in t:
  24. x.append(a*i+b* np.sin(2*ma.pi*w*i)+c)
  25. for i in range(len(x)-len_seq):
  26. Datax.append([x[i:i+len_seq]])
  27. Datay.append([x[i+1:i+len_seq+1]])
  28. Datax = np.array(Datax)
  29. Datay = np.array(Datay)
  30. return(Datax,Datay)
  31. def creation_x_sin2_RNN(len_seq,tmin,tmax,n,w,a=1,b=1,c=0):
  32. Datax, Datay = [], []
  33. t = np.linspace(tmin,tmax,n)
  34. x=[]
  35. for i in t:
  36. x.append(a*i+b*np.sin(2*ma.pi*w*i)*np.sin(2*ma.pi*w*i)+c)
  37. for i in range(len(x)-len_seq):
  38. Datax.append([x[i:i+len_seq]])
  39. Datay.append([x[i+1:i+len_seq+1]])
  40. Datax = np.array(Datax)
  41. Datay = np.array(Datay)
  42. return(Datax,Datay)
  43. def creation_sin(tmin,tmax,n,w,a=1,c=0):
  44. Lx=[]
  45. t = np.linspace(tmin,tmax,n)
  46. for i in t:
  47. Lx.append(a*np.sin(w*i)+c)
  48. Lx=np.array(Lx)
  49. return(t,Lx)
  50. def creation_x_sin(tmin,tmax,n,w,a=1,b=0,c=0):
  51. Lx=[]
  52. t = np.linspace(tmin,tmax,n)
  53. for i in t:
  54. Lx.append(a*i+b* np.sin(2*ma.pi*w*i)+c)
  55. Lx=np.array(Lx)
  56. return(t,Lx)
  57. def creation_x_sin2(tmin,tmax,n,w,a=1,b=1,c=0):
  58. Lx=[]
  59. t = np.linspace(tmin,tmax,n)
  60. for i in t:
  61. Lx.append(a*i+b*np.sin(2*ma.pi*w*i)*np.sin(2*ma.pi*w*i)+c)
  62. Lx=np.array(Lx)
  63. return(t,Lx)
  64. def creation_x(tmin,tmax,n):
  65. Lx=[]
  66. t= np.linspace(tmin,tmax,n)
  67. for i in t:
  68. Lx.append(i)
  69. return(t,np.array(Lx))
  70. def creation_arctan(tmin,tmax,n):
  71. Lx=[]
  72. t= np.linspace(tmin,tmax,n)
  73. for i in t:
  74. Lx.append(np.arctan(i))
  75. return(t,np.array(Lx))
  76. def creation_x2(tmin,tmax,n):
  77. Lx=[]
  78. t= np.linspace(tmin,tmax,n)
  79. for i in t:
  80. Lx.append(i**2)
  81. return(t,np.array(Lx))