编程辅导 C C++ Java Python MIPS Processing 网络家教 在线辅导

编程家教 远程写代码 Debug 讲解答疑 课后答疑 不是中介,本人直接答疑

微信: ittutor QQ: 14061936 Email: ittutor@qq.com

导航

 

 

 

Programme Design Based on Functional Decomposition

 

Objectives:

This assignment is designed for you to gain experience in software development, which includes specification analysis, programme structure design, coding, testing, programme integration and documentation.

 

A formal report that has the following contents:

 

1. Introduction

A brief introduction to the objectives of this assignment.

 

2. Specification Analysis

Input/output data, major tasks involved in the programme.

 

3. Programme Design

Pseudo-English, Hierarchy Chart for the whole programme;

N-S chart and data table for each module.

 

4. Test Strategy

Module test -- Flow graph, basis set of executable paths, and discussion on how to force the programme execution to go through each independent path. Perform loop test if such a need arises.

Integration test – Top-down method, use of dummy modules. State how you have tested your programme.

Validation test -- Choice of typical set of values for the input and validate the output.

 

5. Results and Discussion

Run at least two cases, one for a straight line fitting and the other for a polynomial curve fitting. The content of the input and output text files should be included in your submission. You can also discuss the problems you encountered.

 

After you obtain the output data file, open it with Microsoft Excel to plot the original discrete data and those from the fitting as a curve. You do not need to use your programme to plot the curves!

 

Give a discussion on the performance of your programme.

 

6. A brief User Manual that explains

·         How input data file should be prepared (layout)

·         Arrangement of data in the output file

·         How to input the path and name of the input/output files

 

7. The print-out of the source code should be included as an Appendix.

 

Read the Next Page Carefully

 
 

Specification:

 

A programme is required to fit curves, using a regression analysis, to data sets read from a text file.  A set of x,y data pairs are to be read from a file (each line of the file containing an x value and a y value separated by a comma). The user should be able to select between fitting a straight line or a second order polynomial equation to the data pairs. The coefficients of the best fit curve to these points are then calculated.  The programme should produce an output file and show a message to the user when it finishes a fitting process. Additionally, the programme should

 

1.    ask the user to input the path and name of the input data file,

2.    ask the user to input the path and name of the output data file.

 

The output file should have the following layout

1.    The first line of the file indicates the type of equation derived (line or polynomial);

2.    The second line of the file contains the coefficients of the best fit curve.

3.    From the third line, each line contains an original x value, an original y value and a calculated value of y from the best fit equation for the original x).  The values need to be separated by a comma. The output file has the following format

 
 
 


Line or polynomial

The coefficients of the derived equation

Original x1, original y1, calculated cy1

              Original x2, original y2, calculated cy2

              …

 

 

 

 

 

 

 

 

The program must be designed in modular form ! 

 

 

The algorithms for curve fitting are seen in the Appendix. 

Appendix: Curve fitting algorithms

 

 

Curve fitting

 

Given a set of x,y data pairs it is often necessary to automatically calculate an equation which gives the best fit line through the data.  This type of analysis is known as curve fitting or regression analysis. 

 

The mathematical basis behind curve fitting is quite straightforward.  You have a set of data pairs represented by (x1,y1), (x2,y2) ..... (xn, yn).  You want an equation which represents this data, the exact type of equation will depend on the way in which the data varies (there is no point trying to fit a straight line to a set of data which is obviously not straight).  Given any mathematical relationship between x and y it should be possible to generate a curve fitting algorithm.  Two examples are discussed here.

 

 

Straight line

 

The equation for a straight line is: y = ax + b. Suppose that we have n pairs of (x,y) values from the text file, the values of a and b for the best fit line to the data pairs can be obtained from the following equation

 

     ,

 

where

,  

,          ,

,      

 

The value of a second order determinant  is the difference between the two cross products (a1b2 - a2b1). It is easy to create a C++ function to calculate its value.

 

 

 

 

 

 

Second order polynomial

 

If we wish to fit the curve: y = ax2 + bx + c to the data pairs, we can follow a similar approach to that for a straight line. The values of a, b and c for the best fit curve can be calculated from the following equation

 

 

   ,     ,

 

where

,    ,  

,          

,          ,         

,        ,     

 

 

Solving a third order determinant is fairly simple in that the solution can be broken down to utilise a function written to solve second order determinants:

 

 

You can use a C++ function to calculate the value of a third order determinant. The 9 elements in the determinant can be passed into the function by a two-dimensional array.

 

Introduction 5%

Specification analysis 5%

Programme analysis and design 35%

       If there is sufficient evidence showing that you write the code before you start the design, a maximum of 15% can only be awarded.

Working programme with code matching design 20%

       Sufficient comments should be present in the source code.

Test Strategy     20%

       Should be clear and concise.

User Manual 5%

Report Writing 10%

 

相关推荐