Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plt
- import numpy as np
- import time
- # Построить точки (для построения равномерного распределения)
- def DrawDots(x):
- x_draw, y_draw = np.array([]), np.array([])
- for i in range(0, int(len(x)), 2):
- if i+1 >= len(x):
- break
- x_draw = np.append(x_draw, x[i])
- y_draw = np.append(y_draw, x[i + 1])
- plt.plot(x_draw, y_draw, 'o')
- plt.grid(True)
- plt.show()
- #Построить гистограмму(для построения нормального,экспоненциального и распределения по Коши)
- def DrawHistogram(beg, end, down, up, X):
- h = 0.1
- x = np.arange(beg, end+h, h)
- Y = np.array([])
- for i in range(1, len(x)):
- temp = 0
- for j in range(len(X)):
- if X[j] > x[i - 1] and X[j] <= x[i]:
- temp += 1
- Y = np.append(Y, temp/len(X))
- x = np.delete(x, 0)
- plt.axis([beg, end, down, up])
- plt.grid(True)
- plt.bar(x, Y)
- plt.show()
- # R(0, 1), N – количество элементов
- def RStandart(N):
- # const
- c1 = 4096
- c2 = 150889
- c3 = 714025
- nk = np.array([])
- xk = np.array([])
- # init
- n0 = np.mod(time.time(), c1)
- nk = np.append(nk, n0)
- xk = np.append(xk, nk[0]/c3)
- for i in range(1,N):
- nk = np.append(nk, np.mod(c1*nk[i-1] + c2, c3))
- xk = np.append(xk, nk[i]/c3)
- return xk
- # Строим равномерное распределение
- R = RStandart(5000)
- DrawDots(R)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement