ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 08 May 2017 My Price 9.00

APSC 177 Engineering Computation and Instrumentation Lab 6

Hello Nitinlodhi, can you solve these 2 exercises within the next three days ?

Hassan

 

  1. APSC 177 Engineering Computation and Instrumentation Lab 6 File Input and Output Introduction In many engineering applications, created or measured data contains a signal of interest plus noise. The noise causes the data to vary in a random way (often dramatically) such that it becomes difficult to see trends in the signal. It is typically desirable to reduce the impact of noise on the signal by smoothing the data. Smoothing reduces large and short-­‐term variations in the data. There are many methods that may be used to smooth data. A simple one is to replace each data point with the median of three data points – the data point of interest, the data point before it, and the data point after it. The median of a set of numbers is the “middle” number when the list of numbers is sorted in ascending order. In other words, it is the value above which half of the numbers lie and below which the other half of the numbers lie. For example, the median of the three numbers 8, 1, 2 is 2. Note that the median is different than the average (or mean). To smooth a set of numbers using the median method, a “window” three numbers wide is “slid” across the list of numbers. The number in the centre of the window is replaced with the median of the three numbers in the window. For example, below is a list of “noisy” numbers. The lines above and below the list represent windows three numbers wide. Above (or below) each window is the median value for the three numbers in that window. If the process is repeated throughout the list, the result is the list of smoothed numbers shown below the list of noisy numbers. Noisy List 2 2 3 -­‐5 2 -­‐8 6 -­‐7 -­‐6 7 9 2 1 -­‐5 -­‐7 Smoothed List 3 2 -­‐5 2 -­‐7 -­‐6 -­‐6 7 7 2 1 Notes: -­‐ This method requires that the list contain a minimum of three numbers. -­‐ The list may contain an even or odd number of numbers. -­‐ The first and last numbers in the list are unchanged. -­‐ For this lab a smoothed number will NOT be used to smooth the next number in the list. In other words, only original (noisy) numbers are used when calculating median values. APSC 177 Lab 6 1 In this lab, you will write a C++ program that will read a sequence of numbers from a file and smooth the numbers using the median method described above. The program will then write the original numbers and smoothed numbers to a different file in addition to the average and standard deviation of the numbers before smoothing and after smoothing (see Lab 4 for average and standard deviation equations). Pre-­‐lab Assignment Rather than draw a flowchart or write pseudocode, do a hand example (on paper) of the median smoothing method for the following list of noisy numbers. 2 6 4 3 -­‐4 9 10 7 0 16 11 Show the smoothing process by writing the median value above each window of three numbers across the list of noisy numbers (like on the previous page). Then write out the list of smoothed numbers. Calculate and show the average and standard deviation of the list of noisy numbers and the average and standard deviation of the list of smoothed numbers. Which metric (average or standard deviation) demonstrates the “improvement” in smoothed numbers? Explain. Your hand example is due at the START of your lab class and is worth 20% of this lab’s grade. Program Specification Write a C++ program that does the following: -­‐ Prompts the user to enter the name of the input file that contains the noisy numbers. -­‐ Checks for input file open failure. If a failure occurs, notify the user and terminate the program. -­‐ Prompts the user to enter the name of the output file to which the noisy numbers, smoothed numbers, and the average and standard deviation of both lists will be written. -­‐ Checks for output file open failure. If a failure occurs, notify the user and terminate the program. -­‐ Reads in the noisy numbers from the input file. -­‐ Calculates the average and standard deviation of the list of noisy numbers. -­‐ Smooths the list of noisy numbers to create a list of smoothed numbers. -­‐ Calculates the average and standard deviation of the list of smoothed numbers. -­‐ Writes the list of noisy numbers, the list of smoothed numbers and the average and standard deviation of both, to the output file. APSC 177 Lab 6 2 Files Formats In your work directory you will find an input file called datain.txt. DO NOT CHANGE OR DELETE THIS FILE!! This file contains numbers written in rows and separated by spaces (i.e. the first number in the file is the first number in the first row, the second number in the file is the second number in the first row etc.). You may assume that your program will be tested with input files of similar format (i.e. the sequential ordering of the numbers follows rows and the numbers are delimited by whitespace). The number of numbers in the input file (as well as the number of numbers per row) may vary. Note that there is no sentinel or trailer in the input file and that the number of numbers in the file is not indicated at the start of the file. The format of the output file must be as follows: -­‐ noisy numbers in the first column -­‐ smoothed numbers in the second column -­‐ average and standard deviation of both lists at the end of the file with appropriate wording When writing to the output file, use formatting manipulators to make the columns of numbers evenly spaced and write all numbers with two decimal places. Below is an example of what the output file could look like. Because your output will be marked manually by your Lab instructor, it need not look exactly as below. However, your lab instructor will be looking for an aesthetically pleasing output file format. Feel free to improve on the formatting of the output file over that shown below. 1.10

1.10
0.33
0.33
-6.80
0.33
3.84
3.84
4.90
4.90
noisy average = 0.68
smoothed average = 2.10
noisy standard deviation = 4.58
smoothed standard deviation = 2.13 Notes: -­‐ Remember to add comments to your code. -­‐ Initially, while testing your smoothing algorithm, you may wish to print the noisy list of numbers and the smoothed list of numbers (as well as their averages and standard deviations) to the screen rather than the output file. Once you are certain your program correctly smooths the numbers and correctly calculates the metrics, then write to the output file. -­‐ To test your code, create a file in your Vocareum work directory (call it something other than datain.txt) containing the set of numbers that you used in APSC 177 Lab 6 3 
the pre-­‐lab assignment since you already know the smoothed version of that set of numbers and the corresponding averages and standard deviations. Lab Submission Be sure to test your program with various noisy data sets to make sure it works for different scenarios. When your program is working, demonstrate it to your lab instructor. He/she will ask you a question regarding your program or ask you to make a minor modification. When you have successfully answered the question or made the modification, submit your program via Vocareum. If you were asked by your lab instructor to make a modification, be sure to undo your modification (i.e. return your program to its original state) prior to submission. You must submit your program before the end of your lab class, it must be called Lab6.cpp, and it must be submitted within the Lab 6 assignment in Vocareum. Lab programs submitted after 11:00 PM will receive a mark of zero for the “After the submission of your lab” component of the lab marks. In other words, the maximum score a late lab can obtain is 4/10 (hand example and modification/question). Even if your program does not compile or run correctly, submit it by 11:00 PM on the day of your lab class. APSC 177 Lab 6 4 APSC 177 Engineering Computation and Instrumentation Assignment 9 Writing a Function with Pointers Due Date: Saturday December 3, 2016 at 11 PM Submit via Vocareum NOTE: You have only ONE submission attempt for this assignment. No Exceptions. Function Objective Write a function that takes a list of numbers, as well as the number of numbers in the list, and returns, using pointers, the minimum number in the list and the maximum number in the list. Function Specifications − Your function must have the name minmax − Your function must have four formal parameters. The first is of type double, the second is of type int, and the third and fourth are of type double. − The first parameter is a pointer (passed by value) that points to the first element of the array holding the numbers. − The second parameter is the number of numbers in the array and must be passed by value. − The third parameter is a pointer (passed by value) that points to a variable that will end up holding the minimum number in the array. − The fourth parameter is a pointer (passed by value) that points to a variable that will end up holding the maximum number in the array. − The return type for your function must be void. − Your function should work with all positive and/or negative real numbers. In your Vocareum work directory you will find two files. Do not delete or rename either of these files. One file is named Assignment9_function.cpp. You must write your minmax function definition (and only your function definition) in this file. The second file is called Assignment9_main.cpp. In this file you will find the proper prototype for the function minmax, and a main function that allows the user to enter the numbers in the list, calls the function minmax, and then displays the minimum and maximum numbers in the list as provided by the function minmax. You should use this main function to test your minmax function. Note: Do NOT change or add to any of the code in Assignment9_main.cpp. Note: Your minmax function will be graded using the given minmax prototype and main function in Assignment9_main.cpp. APSC 177 Assignment 9 1 Note: When you click Build or Run in Vocareum, your code in Assignment9_function.cpp and the code in Assignment9_main.cpp will be linked together and compiled (and then executed if you click Run). Submission and Grading Details Before you submit your function make sure you test it with a variety of different lists of numbers. Remember, you have only ONE submission attempt. No Exceptions. APSC 177 Assignment 9 2

Answers

(11)
Status NEW Posted 08 May 2017 12:05 AM My Price 9.00

-----------

Not Rated(0)