Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to apply SNR to Guassian White Noise? #89

Open
djnotes opened this issue Nov 12, 2022 · 3 comments
Open

How to apply SNR to Guassian White Noise? #89

djnotes opened this issue Nov 12, 2022 · 3 comments

Comments

@djnotes
Copy link

djnotes commented Nov 12, 2022

I have an exercise that requires applying a guassian white noise with signal to noise ratio of 10 dB on a sine signal with amp=1, sampling rate=1 Hz, duration=1 and freq=3 Hz.
The question then requests application of some filtering with cut-off and moving average.

The guassian noise implementation in thinkdsp does not take a SNR parameter. I didn't find anything signal to noise ratio in the book. Is it possible to solve this problem using thinkdsp and Python?

noise = thinkdsp.UncorrelatedGaussianNoise()

@AllenDowney
Copy link
Owner

Should be doable. You can generate a signal with the SNR you want by generating a sine signal as specified and then adding white noise with the power ratio you want. For SNR=10 dB, the power of the white noise should be one tenth the power of the sine signal. Is that enough to go on?

@djnotes
Copy link
Author

djnotes commented Nov 12, 2022

Still a bit confused. Does this mean?

sinSig = ... # the sine signal
noise = 1/10 * thinkdsp.UncorrelatedGaussianNoise()
mix = sinSig + noise

@AllenDowney
Copy link
Owner

Yes, but you'll need to use UGN to generate a Wave with the same length as your signal. And dividing the amplitude by 10 divides the power by 100. Also, you might want to compute the power of both Waves before to check whether they have the same power before you divide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants