I have a dataframe that is a sine wave with slight noise, and I want to increase the noisiness at only one particular place of the plot. The noise should increase at a certain point before reducing again. For example, at point 400 here:
My current code for the dataframe without the increase in noise is as follows:
samples_per_cycle = 333
num_cycles = 3
amp_min, amp_max = -100, 100
t = np.linspace(0, num_cycles*2*np.pi, num_cycles*samples_per_cycle)
noise = np.random.normal(0, 0.05, num_cycles*samples_per_cycle)
t = t + noise
y = amp_min + ((1+np.sin(t))/2)*(amp_max-amp_min)
A = y
A_int = np.array(A, dtype=int)
generated_df = pd.DataFrame(
{'A': A_int,
})
If you want to add noise at particular subsection of the array, you can just reference a certain index range of t. For example, here's how to add noise to t from index 400 to 500
Just add this to your code below t = t + noise
#Length of noise2 needs to match subsection of t you want to add noise to
noise2 = np.random.normal(0, 0.2, 100)
t[400:500] = t[400:500] + noise2