300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > python生成高斯(gauss)数据并保存为txt文件

python生成高斯(gauss)数据并保存为txt文件

时间:2022-01-04 08:05:38

相关推荐

python生成高斯(gauss)数据并保存为txt文件

1.数据目标公式

G(x)=1000∗e−4∗ln2∗(x−91)2/0.52+0.3∗x2+2∗x+100G(x) = 1000 * e^{-4*ln2*(x-91)^2 / 0.5 ^2}+ 0.3 * {x}^2 + 2 * {x} + 100G(x)=1000∗e−4∗ln2∗(x−91)2/0.52+0.3∗x2+2∗x+100

2.代码

import numpy as npimport matplotlib.pyplot as pltdef generate_gauss():num_data = 71x = np.array(np.linspace(89, 93, num_data)).reshape(num_data, 1) # 产生包含噪声的数据y = 1000 * np.exp((-4 * np.log(2) * (91 - x) ** 2) / 0.5 ** 2) + 0.3 * x ** 2 + 2 * x + 100a = np.hstack((x, y))plt.scatter(x, y)plt.show()np.savetxt(r'C:\Users\gauss.txt', a, fmt='%f', delimiter='')if __name__ == '__main__':generate_gauss()

3.函数图像

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。