On the file i sent. Thanks
ver_2_ENGG1811 Assignment 1 2020 ENGG1811 20T3 (revision 1 13th Oct 2020) Assignment 1: Peak Detection Learning Objectives: 1. To apply programming concepts of variable declaration, constant declaration, assignment, selection and iteration (for loop). 2. To translate an algorithm described in a blend of natural language and elements of pseudocode to a computer language. 3. To organise programs into smaller modules by using functions. 4. To use good program style including comments, meaning variable names and others. 5. To get a practice on software development, which includes incremental development, testing and debugging. Aaron Quigley, October, 2020 Deliverables: Submit by 17:00 on Wednesday of Week-07.
Late Penalty: Late submissions will be penalised at the rate of 10% per day (including weekends). The penalty applies to the maximum available mark. For example, if you submit 2 days late, maximum available marks is 80% of the assignment marks.
Submissions will not be accepted after 9am Monday of Week-08. To Submit this assignment, go to the Submission page and click the link named "Make Submission". GENERAL RULES 1. This assignment is weighted at 20% 2. You are reminded that work submitted for assessment must be your own. It's OK to discuss approaches to solutions with other students, and to get general help from tutors or others, but you must write the python code yourself. Increasingly sophisticated software is used to identify submissions that are unreasonably similar, and marks will be reduced or removed in such cases. 3. The Student Code of Conduct sets out what the University expects from students as members of the UNSW community. As well as the learning, teaching and research environment, the University aims to provide an environment that enables students to achieve their full potential and to provide an experience consistent with the University's values and guiding principles. A condition of enrolment is that students inform themselves of the University's rules and policies affecting them, & conduct themselves accordingly. (see the course outline page with links). 4. You should also read the following page which describes your rights and responsibilities in the CSE context: Essential Advice for CSE Students Essential The University views plagiarism very seriously. UNSW and CSE treat plagiarism as academic misconduct, which means that it carries penalties as severe as being excluded from further study at UNSW. [see: UNSW Plagiarism Procedure] Change Log 1. Your functions max_peak, total_peaks, peak_list_from_file should import peak_list in your code for these three functions [Updated Oct 13th]. 2. If there are no peaks in the inputs given max_peak should return the string “No Peaks” [Updated Oct 13th] 3. The text file format is one number per line (as shown in voltage_data_complete.txt in week 3) [Update Oct 13th] 4. For the purposes of this assignment we are only looking to identify peaks above the mean (and we will only test for such conditions) [Oct 13th] https://student.unsw.edu.au/conduct https://webcms3.cse.unsw.edu.au/ENGG1811/20T3/outline https://www.engineering.unsw.edu.au/computer-science-engineering/about-us/organisational-structure/student-services/policies/essential-advice-for-cse-students https://student.unsw.edu.au/plagiarism https://www.gs.unsw.edu.au/policy/documents/plagiarismprocedure.pdf https://www.gs.unsw.edu.au/policy/documents/plagiarismprocedure.pdf ENGG1811 20T3 (revision 1 13th Oct 2020) Assignment 1: Peak Detection What you must submit total_peaks.py max_peak.py peak_list.py peak_list_from_file.py The General Problem: Peak Detection In this assignment, your goal is to write a python program to determine various characteristics about some time series data you are given. These types of problems are very common in many disciplines, including computer science, engineering, medicine and science. There are many different types of peak detection problems, the setting of this assignment is similar to that used in pulse oximeter data. The method described below is based on a sliding window which allows us to calculate a standard score of the number of standard deviations aways from the mean a value is. Such peak detection has been used to understand the periodic distributions of nucleotides from the genome of SARS-CoV-2 had been sequenced and structurally annotated or pollution peaks or heart rate detection. Peak detection is a very common task in the understanding of data. The Algorithmic Problem What is a “peak” and how can we reliably detect them! Let’s step back to some basic stats. For a finite normal population with N members, the population mean is the following (mu): Variance is a measure of dispersion (spread). For a finite normal population with N members, the population variance is the following (sigma squared): Standard deviation is a also measure of dispersion (spread). The standard deviation of the population is the square root of the variance, it is written as (sigma): Aaron Quigley, October, 2020 ∑ = = N i ixN 1 1 µ ( )∑ = −= N i ixN 1 22 1 µσ Oct 7th tip: Please read the entire practical first and think carefully about the order in which you might implement these functions! ENGG1811 20T3 (revision 1 13th Oct 2020) Assignment 1: Peak Detection [Basic Standard Deviation diagram: Source Wikipedia] “A low standard deviation indicates that the values tend to be close to the mean (also called the expected value) of the set, while a high standard deviation indicates that the values are spread out over a wider range.” Observation: 1 In statistics, the z-score of “standard score” says, how many standard deviations is a data point above or below the mean value of what is being observed. As such, looking for values within our data with “high” z-scores might be a way to identify peaks in our data. Observation: 2 We can determine the mean by looking at all the data. Or we could determine a moving mean value for data within a given window, not for all the data we are observing. We can refer to this “smoothing window” or lag as our “window”. Observation: 3 Finally, when we do observe something above a particular z-score we can decide how much (if at all) this should influence the moving mean value for the data within this window or subsequent windows. Description of the peak detection algorithm The goal is to detect does a particular part of an input signal have peaks and if so where. In the following example, the peak to be detected is a sequence of 20 numbers (see Fig 1) begins at the 9th element in the input list and ends at the 12th element. However, if you look at the input list you can see lots of smaller up and down patterns in the data which could each be considered peaks. So, what makes 9 - 12 a peak while the others aren’t. Firstly, the values 41, 38, 22 and 10 are beyond the average. How far beyond the average? Well at least 3 standard deviations in this case. The next question is, Aaron Quigley, October, 2020 68% within 1 standard deviation 99.7% within 3 standard deviations 95% within 2 standard deviations 68–95–99.7 rule ENGG1811 20T3 (revision 1 13th Oct 2020) Assignment 1: Peak Detection what “average”. Well we use an “moving mean” or sliding window to calculate the average within a window of the last N values (in this case 8). However, you might be wondering, by the time the input value of 10 is considered surely the average of the last N numbers of the smoothing window (22, 38, 41, 0 … etc.) suggests that 10 isn’t that far away from the mean. This is where the notion of “influence” comes in. When we are considering the input we must filter it so that when we do detect a Aaron Quigley, October, 2020 Figure 1: Input signal. Plot of input and
detected peaks (based on a given window of 8 and z-score of 3 and an input peak influence of 0) Figure 2: Input and how we calculate the average and the
standard deviation for the first input value in list s we consider ENGG1811 20T3 (revision 1 13th Oct 2020) Assignment 1: Peak Detection peak value, then those input values are treated differently than when we aren’t seeing inputs from a peak value. Implementation requirements You need to implement the following four functions, each in a separate file.
Your functions max_peak, total_peaks, peak_list_from_file should import peak_list in your code for these three functions [Updated Oct 13th].
You need to submit these four files, each containing one function you implement 1. def total_peaks(inputs, smoothing, th, influence): • The aim of this function is to calculate the total number of distinct peaks measured in the inputs given • The first parameter 'inputs' is a list of (float) values, and the second parameter 'smoothing' is the size of the window used to determine the meaning average, the third parameter is the z-score (or how many standard deviations away from the moving mean does the input need to be for it to be considered a peak) and finally the ‘influence’ says how much should a value which is considered a peak value effect the moving average • The function should could the number of distinct “peaks” in the inputs given (a peak should be considered as a continuous unbroken series of 1 1 1 values) • This function can be tested using the file ‘test_total_peaks.py'. Aaron Quigley, October,