Question
Language: Python Program used: PyCharm Interpreter: 3.6.1 at ~/anaconda/bin/python ---------- ---------- Starter code: import matplotlib.pyplot as plt import math as m import random as rand
Language: Python
Program used: PyCharm
Interpreter: 3.6.1 at ~/anaconda/bin/python
----------
----------
Starter code:
import matplotlib.pyplot as plt import math as m import random as rand
# This code generates the transmitted and received signals. # x are the values (in radians) at which the transmitted sin function was evaluated # (used for the x-coordiantes when plotting) # y is the list of amplitude values in the transmitted signal # y_noisy is the received signal corrupted by random noise # # DO NOT EDIT THIS CODE!
x = [ d * m.pi / 180 for d in range(360*3)] y = [m.sin(k) for k in x ] y_noisy = [m.sin(k) + rand.gauss(0, .1) for k in x]
# Part (a): # Write your function for moving average filtering here. See the assignment description # for details.
# part (b): # write a function call here to filter y_noisy with a filter of radius 9 and obtain the filtered signal.
# part (c): # Now write code to plot the noisy signal and the filtered signal in separate figure windows. # Note that because a new noisy signal is generated by adding random noise each time the function # is run, the noisy and filtered signals will look slightly different each time you run the program. # Try to make the figures look as close as possible to the figures in the assignment description. # The functions from matplotlib.pyplot that may be useful for this are as follows: # # figure(), plot(), show(), xlim(), ylim(), xlabel(), ylabel(), title()
# You need to call plt.figure() once for EACH figure you prepare. Uncomment this line when you are ready #plt.figure()
# PLOT THE ORIGINAL, NOISY SIGNAL HERE
#plt.figure()
# PLOT THE SMOOTHED SIGNAL HERE
Question 2 (8 points): Purpose: To practice slicing, Lists, and plotting Degree of Difficulty: Moderate; the length of the write-up makes it seem harder than it really is Humans have managed to build many types of sensors from radio receivers to digital camera sensors. Any sensor that we have engineered is subject to some kind of inaccuracy or noise. Noise refers to any component of a detected signal that is not actually part of the signal we intended to detect. Radio receivers can be influenced by external electromagnetic radiation sources other than the transmitter, or the signal itself can be damaged by atmospheric distortions. Digital camera sensor elements are not all created equal due to imperfect manufacturing processes, and have slightly different sensitivity to light, causing graininess in photographs A lot of effort has gone into researching ways of filtering out noise in signals received by a detector. It is a challenging problem because the detector doesn't know what the original signal was. The detector's only knowledge" is the noisy signal it received, and perhaps some general assumptions about what kind of noise might be present in a signal For example, we might know that the amplitude values of a radio signal are all too high or too low by different random amounts, that is, the signal contains random noise. Many real sources of noise are indeed random in this way Suppose we transmit a perfect sine wave, as seen below on the left. Due to noise (perhaps the random noise we mentioned above), the received signal ends up looking like the one on the right Received 1.5 1.5 1.0 0.5 0.5 0.0 0.0 -0.5 -0.5 10 15 10 15 x in Radians x in Radians These signals are represented digitally by a list of numbers which are the received amplitudes of the signal at each sampled time point. An easy way to greatly reduce (but not entirely eliminate) such noise is to replace each received amplitude value by the average of itself, the r amplitudes immediately to the left, and the r amplitudes immediately to the right. In other words, each amplitude is replaced by an average of the 2r +1 nearest amplitudes. This technique is called a moving average filter because we move along the signal replacing each amplitude with the average of its neighbours. We call r the radius of the filter, and it defines which neighbours get included in the average Below, we show a schematic of how a moving average works on a list of numbers representing signal amplitudes when r = 2 Question 2 (8 points): Purpose: To practice slicing, Lists, and plotting Degree of Difficulty: Moderate; the length of the write-up makes it seem harder than it really is Humans have managed to build many types of sensors from radio receivers to digital camera sensors. Any sensor that we have engineered is subject to some kind of inaccuracy or noise. Noise refers to any component of a detected signal that is not actually part of the signal we intended to detect. Radio receivers can be influenced by external electromagnetic radiation sources other than the transmitter, or the signal itself can be damaged by atmospheric distortions. Digital camera sensor elements are not all created equal due to imperfect manufacturing processes, and have slightly different sensitivity to light, causing graininess in photographs A lot of effort has gone into researching ways of filtering out noise in signals received by a detector. It is a challenging problem because the detector doesn't know what the original signal was. The detector's only knowledge" is the noisy signal it received, and perhaps some general assumptions about what kind of noise might be present in a signal For example, we might know that the amplitude values of a radio signal are all too high or too low by different random amounts, that is, the signal contains random noise. Many real sources of noise are indeed random in this way Suppose we transmit a perfect sine wave, as seen below on the left. Due to noise (perhaps the random noise we mentioned above), the received signal ends up looking like the one on the right Received 1.5 1.5 1.0 0.5 0.5 0.0 0.0 -0.5 -0.5 10 15 10 15 x in Radians x in Radians These signals are represented digitally by a list of numbers which are the received amplitudes of the signal at each sampled time point. An easy way to greatly reduce (but not entirely eliminate) such noise is to replace each received amplitude value by the average of itself, the r amplitudes immediately to the left, and the r amplitudes immediately to the right. In other words, each amplitude is replaced by an average of the 2r +1 nearest amplitudes. This technique is called a moving average filter because we move along the signal replacing each amplitude with the average of its neighbours. We call r the radius of the filter, and it defines which neighbours get included in the average Below, we show a schematic of how a moving average works on a list of numbers representing signal amplitudes when r = 2Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started