简体   繁体   English

如何将高斯噪声(10%)添加到一组数据点

[英]How to add gaussian noise (10%) to a set of datapoints

i have a set of 100 point (2-dimensional, xy). 我有一套100点(2维,xy)。 I have to add to each x-coordinate a 10% gaussian noise. 我必须在每个x坐标上添加10%的高斯噪声。 The 10% is referred to each x-value. 10%是指每个x值。 I've found around this line of code: 我发现这行代码:

noisy_data = exact_data
relativeError = 0.1
noisy_data[:,0] = [ np.random.normal(loc=value, scale=abs(relativeError*value)) for value in noisy_data[:,1]] 

I'm not sure this is the right way to do that. 我不确定这是否是正确的方法。 Do you know if it is correct? 你知道它是否正确吗? If not, is there a function that can do it properly? 如果没有,是否有能够正确完成的功能?

It sounds to me like the y values don't matter. 听起来像y值并不重要。 Also, there's no need to iterate over each element. 此外,没有必要迭代每个元素。

noisy_data = exact_data.copy()
noisy_data[:, 0] += np.random.normal(loc=0, scale=abs(relativeError*noisy_data[:, 0]))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM