Write a python program to determine a given pattern appears

Assignment Help Python Programming
Reference no: EM131955880

Assignment -

The pattern detection problem - In this assignment, your goal is to write a python program to determine whether a given pattern appears in a data series, and if so, where it is located in the data series. This type of problems is very common in many disciplines, including computer science, engineering, medicine and science. There are many different types of pattern detection problems, the setting of this assignment is similar to that used in radars. A radar transmits a pulse of a specific shape and waits for a pulse of similar shape to return, in order to determine the position of an object. The method described below is known as matched filtering and is widely used in communication systems. This means your mobile phones perform the same type of calculations that you will be programming below!

Learning objectives - By completing this assignment, you will learn:

1. To apply programming concepts of variable declaration, constant declaration, assignment, selection and iteration (for loop).

2. To translate an algorithm described in a natural language to a computer language.

3. To organize 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.

Implementation Requirements -

You need to implement the following four functions, each in a separate file (provided). You need to submit these four files, each containing one function you implement.

1. def calculate_similarity(data segment, pattern):

  • The aim of this function is to calculate the similarity measure between one data segment and the pattern.
  • The first parameter idata_segment is a list of (float) values, and the second parameter 'pattern' is also a list of (float) values. The function calculates the similarity measure between the given data segment and pattern and returns the calculated similarity value (float), as described earlier in this assignment. The function returns "Error" if 'data_segment' and 'pattern' have different lengths.
  • This function can be tested using the file 'test_calculate_similarity.py'.

2. def calculate_similarity_list(data series, pattern):

  • The aim of this function is to calculate the similarity measures between all possible data segments and the pattern.
  • The first parameter 'data_series' is a list of (float) values, and the second parameter 'pattern' is also a list of (float) values. The function calculates the similarity measures, using the above function 'calculate_similarity', of all possible data segments in a sequence, and returns the list of calculated similarity values.
  • This function can be tested using the file 'test_calculate_similarity_list.py'.

3. def pattern_search_max(data series, pattern, threshold):

  • The three possible outcomes are "Insufficient data", "Not detected" and the location of the pattern if the pattern is found in the data series. Here, the location of the pattern refers to the index of the highest similarity measure that is also greater than or equal to the given threshold value.
  • The first parameter 'data_series' is a list of (float) values, the second parameter 'pattern' is a list of (float) values, and the third parameter 'threshold' is a (float) value. In this function, you need to use the function icalculate_similarity_list.
  • This function can be tested using the file 'test_pattern_search_max.py'.

4. def pattern_search_multiple(data series, pattern_width, threshold):

The three possible outcomes are "Insufficient data", "Not detected" and a list of non overlapping indices that are greater than or equal to the given threshold value, and that satisfy the following criteria:

  • an index is not selected if the value at the index is less than a value at one of it's overlapping indices.
  • an index is not selected if it is overlapping with first or last index.

We say two indices are overlapping if the distance between them is less than the width of the pattern.

The first parameter 'data_series' is a list of (float) values, the second parameter 'pattem_width' is a (float) value, and the third parameter 'threshold' is a (float) value.

This function can be tested using the file 'test_pattern_search_multiple.py'.

Attachment:- Assignment Files.rar

Reference no: EM131955880

Questions Cloud

Describe the distinguishing characteristics : Describe the distinguishing characteristics of each part of the Milky Way.
What is the market price of a face value bond : Chocolate and More offers a bond with a coupon rate of 6 percent, semiannual payments, and a yield to maturity of 7.73 percent. The bonds mature in 9 years.
What do you and your audit team need : PACC6002 Auditing and Assurance Services - Identify and discuss three main factors that will be investigated by each audit manager's group
What are the wave speed and the tension in the string : The linear density of a string is 1.6 x 10^-4 kg/m.A transverse wave on the string is described by the equation
Write a python program to determine a given pattern appears : In this assignment, your goal is to write a python program to determine whether a given pattern appears in a data series
Compute the economic order quantity : Compute the economic order quantity (EOQ). How frequently would the company place na order compared to the oold purchasing policy?
Who are mrs nobles followers : What servant leader behaviors would you say Mrs. Noble demonstrates? Who are Mrs. Noble's followers?
Determine the frequency of friend trombone : Your ear is good enough to detect that your trombone is at a higher frequency. Determine the frequency of your friend's trombone.
What is the market price of chiptech stock : What is the market price of Chiptech stock? The required return for the computer chip industry is 20%, and the company has just gone ex-dividend.

Reviews

len1955880

4/24/2018 6:15:26 AM

Getting Started - Download the zip file asstprelim.zip, and unzip it. This will create the directory (folder) named 'assi_preliml. Rename/move the directory (folder) you just created named 'ass1_prelim' to 'asst. The name is different to avoid possibly overwriting your work if you were to download the 'assi_prelim.zip' file again later. First browse through all the files provided, and importantly read comments in the files. Do not try to implement too much at once, just one function at a time and test that it is working before moving on.

len1955880

4/24/2018 6:15:21 AM

Start implementing the first function, properly test it using the given testing file, and once you are happy, move on to the the second function, and so on. Please do not use 'print' or 'input' statements. We won't be able to assess your program properly if you do. Remember, all the required values are part of the parameters, and your function needs to return the required answer. Do not 'print' your answers.

len1955880

4/24/2018 6:15:16 AM

Testing - Test your functions thoroughly before submission. You can use the provided python programs (files like lest_calculate_similarity.py, stest_pattern_search_max.py', stest_pattern_search_multiple.py', etc.) to test your functions. Please note that the tests provided in these files cover only basic scenarios (cases), you need to think about other possible cases, modify the files accordingly and test your functions. For example, you need to add cases to test for "Insufficient data" and "Not detected" scenarios. Submission - You need to submit the following four files. Do not submit any other files. For example, you do not need to submit your modified test files. calculate_similarity.py, calculate_similarity_list.py, pattern_search_max.py and pattern_search_multiple.py. To Submit this assignment, go to the Submission page and click the tab named "Make Submission".

len1955880

4/24/2018 6:15:09 AM

Five (5) marks are awarded by your tutor for style and complexity of your solution. The style assessment includes the following, in no particular order: Use of meaningful variable names where applicable. Use of sensible comments to explain what you're doing. Use of docstring for documentation to identify purpose, author, date , data dictionary, parameters, return value(s) and program description at the top of the file.

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd