Generate data with normally distributed noise and mean function
<p>I created a numpy array with n values from 0 to 2pi. Now, I want to generate n test data points deviating from sin(x) normally distributed. </p>

<p>So i figured I need to do something like this: <code>t = sin(x) + noise</code>. Where the noise must be something like this: <code>noise = np.random.randn(mean, std)</code>.</p>

<p>However, I do not know how I can calculate the noise when my mean is sin(x) (and not a constant).</p>

<p>If you add the noise to the <code>y</code> coordinate, some of the test data points may have values outside the normal range of the sine function, that is, not from -1 to 1, but from -(1+noise) to +(1+noise). I suggest to add the noise to the <code>x</code> coordinate: </p>

<pre><code>t = np.sin(x + np.random.uniform(-noise, noise, x.shape))
</code></pre>

<p>where <code>noise</code> must be a suitable value to your problem.</p>

python numpy scipy normal-distribution