import numpy as np
import random
import matplotlib.pyplot as plt
# 在0-2*pi的区间上生成100个点作为输入数据
X = np.linspace(0, 10, 200, endpoint=True)
Y = 3*X+4
# 对输入数据加入gauss噪声
# 定义gauss噪声的均值和方差
mu = 0
sigma = 0.52
for i in range(X.size):
X[i] += random.gauss(mu, sigma)
Y[i] += random.gauss(mu, sigma)
# 画出这些点
plt.plot(X, Y, linestyle='', marker='.')
plt.show()
import os
import csv
max_file = 'data_Y.csv'
max_file_path = open(max_file, "w")
print
writer = csv.writer(max_file_path)
writer.writerow(Y)
max_file_path.close()
print('saved')