Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding noise to a signal in python

Tags:

python

I want to add some random noise to some 100 bin signal that I am simulating in Python - to make it more realistic.

On a basic level, my first thought was to go bin by bin and just generate a random number between a certain range and add or subtract this from the signal.

I was hoping (as this is python) that there might a more intelligent way to do this via numpy or something. (I suppose that ideally a number drawn from a gaussian distribution and added to each bin would be better also.)

Thank you in advance of any replies.


I'm just at the stage of planning my code, so I don't have anything to show. I was just thinking that there might be a more sophisticated way of generating the noise.

In terms out output, if I had 10 bins with the following values:

Bin 1: 1 Bin 2: 4 Bin 3: 9 Bin 4: 16 Bin 5: 25 Bin 6: 25 Bin 7: 16 Bin 8: 9 Bin 9: 4 Bin 10: 1

I just wondered if there was a pre-defined function that could add noise to give me something like:

Bin 1: 1.13 Bin 2: 4.21 Bin 3: 8.79 Bin 4: 16.08 Bin 5: 24.97 Bin 6: 25.14 Bin 7: 16.22 Bin 8: 8.90 Bin 9: 4.02 Bin 10: 0.91

If not, I will just go bin-by-bin and add a number selected from a gaussian distribution to each one.

Thank you.


It's actually a signal from a radio telescope that I am simulating. I want to be able to eventually choose the signal to noise ratio of my simulation.

like image 936
user1551817 Avatar asked Dec 27 '12 17:12

user1551817


People also ask

How do you add noise to a signal in Python?

While noise can come in different flavors depending on what you are modeling, a good start (especially for this radio telescope example) is Additive White Gaussian Noise (AWGN). As stated in the previous answers, to model AWGN you need to add a zero-mean gaussian random variable to your original signal.

How do you add noise to an image in Python?

Python – noise() function in Wand We can add noise to the image using noise() function. noise function can be useful when applied before a blur operation to defuse an image.

How do I add Gaussian noise to signal?

y = awgn( x , snr ) adds white Gaussian noise to the vector signal x . This syntax assumes that the power of x is 0 dBW.


1 Answers

You can generate a noise array, and add it to your signal

import numpy as np  noise = np.random.normal(0,1,100)  # 0 is the mean of the normal distribution you are choosing from # 1 is the standard deviation of the normal distribution # 100 is the number of elements you get in array noise 
like image 149
Akavall Avatar answered Oct 02 '22 05:10

Akavall