Question: Using Python, complete a zero-mean problem through code You may work by yourself, or in groups of two. Both partners in each group are expected
Using Python, complete a zero-mean problem through code
You may work by yourself, or in groups of two. Both partners in each group are expected to contribute equally to each part, and will get equal scores. Each group makes a single project submission, with a program header that indicates clearly the names of both group members. For this project, you will write a program with two functions that implement useful data/signal processing operations. Suppose we have an list of data; we are mostly interested in how the data points fluctuate around the mean of the data set. A useful operation is zero-mean normalization; find the mean of the data points, and subtract the mean from each data point. A good illustration: http://www.optimaldesign.com/AMHelp/Other/zeroonemeannorm.htm For example, consider the following list in Python. x = [-.4, -1, 1.0, -5, -.2, .2, -1, -0.5, -.5, .85] The mean of the list is 0.14. After zero-mean normalization, the new list becomes [-.54, -.24, -86, -.34, -0.5, -.04, -.19, -64, -71] After we have performed zero-mean normalization on our data points, another useful operation is to count the number of times the data points cross zero. A zero crossing is counted when neighboring data points have different signs. Zero crossing counts are often used to help identify whether a data set is noisy, detect different types of sounds, etc. Considering the list after zero-mean normalization. The number of zero crossings for this array is 5. (Zero crossings are counted for -24, to .86, 36 to -34, -34, to .06, 0.5, to -0.4, -64 to .71). Write a program that does the following: Prompts the user to enter the number of data points, N(20) Read in N data points (as floats) Perform zero mean normalization the data points Count zero crossings for the normalized data points Print the normalized data points and the zero-crossing count ...and you will get a very similar result to the answer but formatting will be a little off. This useful for rapid testing. A third way is to simply hard code the list as a variable in your code and use that while testing but be sure to remove this before submission so your code will work with any list. A fourth way use the open function from our Chapter 7 examples. See this example if you'd like to try that. http//unixlab.sfsu.edu/ats/csc309/ch7/read_list.py Another infile to test with: Your program must include two functions zmean() and zcross(). The first function, zmean(), takes a list of floats as input. It then returns the newList as output. The second function, zcross(), takes the newList as input and returns the number of zero crossings that occur in the list. Your main() function must call zmean() and zcross() to perform the necessary operations. Programming style and documentation: You must follow the style and documentation guidelines specified in previous projects. In addition, each function must have a header containing the function prototype, description of each argument and return result, and description of what the function does. Submission: Submit your project (the .py file only) via the iLearn submission link. 80% of your grade is for correctness 20% is for clarity/documentation. A sample run: Input from a file: Obviously it gets pretty tedious typing in all the data, up to 20 data points. There are four (probably more) ways to supply the input and simplify testing. The simplest is to have your test input in another file and simply copy and paste the input into the prompt. Another ways called redirecting input from a file in Unix. All you have to do is create a text file that contains all the text that you intend to enter when you run the program. The same input for the previous example has been typed into the text file named in1. To run zcross with input coming from the text file in 1(instead of typing the input manually) simply type at the Unix prompt python zcross. py
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
