Advertisement
575

filter

575
Nov 6th, 2022 (edited)
873
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. # N(0, 1), N – количество элементов
  2. def NStandart(N):
  3.     xk = np.array([])
  4.     # R(0, 1)
  5.     a1 = RStandart(N)
  6.     time.sleep(3) # pause
  7.     a2 = RStandart(N)
  8.  
  9.     for i in range(N):
  10.         xk = np.append(xk, np.sqrt(-2 * np.log(a1[i])) * np.cos(2 * np.pi * a2[i]))
  11.     return xk
  12.  
  13. # Параметры задачи
  14. h = 0.05
  15. t0 = 0
  16. t1 = 10
  17.  
  18. # разностная схема
  19. yij = np.zeros((4,int((t1-t0)/h)))
  20. xN = NStandart(int((t1 - t0)/h))
  21.  
  22. for j in range(1,int((t1 - t0)/h)):
  23.     yij[0][j] = yij[0][j-1] + h * yij[1][j-1] + 2 * np.sqrt(2) * np.pi * h * xN[j-1]
  24.     yij[1][j] = -h * yij[0][j-1] + (1 - 2.5 * h) * yij[1][j - 1] + (np.sqrt(6 * np.pi) - 5 * np.sqrt(np.pi)) * np.sqrt(2 * np.pi) * h * xN[j - 1]
  25.  
  26. # Строим график
  27. t = np.arange(t0, t1, h)
  28. plt.plot(t, yij[1])
  29. plt.grid(True)
  30. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement