DOC PREVIEW
ODU CS 350 - Assignment Kit for Program 3

This preview shows page 1-2-3-4-5-6 out of 18 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Program 3 September 2005 1 © 2005 by Carnegie Mellon University CS 350: Assignment Kit for Program 3 Fall 2005 Version 1.1 (subject to revision)Program 3 September 2005 2 © 2005 by Carnegie Mellon University Personal Software Process for Engineers Assignment Kit for Program 3 Overview Overview This assignment kit covers the following topics. Section See Page Prerequisites 2 Program 3 requirements 3 Numerical integration with Simpson’s rule 4 The t distribution 6 Using the t distribution in the PSP 6 An example 9 Assignment instructions 11 PSP1 planning script 12 Due dates and evaluation criteria 18 Prerequisites Reading • Chapters 6Program 3 September 2005 3 © 2005 by Carnegie Mellon University Program 3 requirements Program 3 requirements Using PSP2, write a program to numerically integrate a function using Simpson’s rule. Use the t distribution as the function. Thoroughly test the program. At a minimum, calculate the values for the t distribution integral for the values in Table 1. Expected values are also included in Table 1. Test Expected Value Actual Value x dof p 0 to x= 1.1 9 0.35005864 0 to x= 1.1812 10 0.36757341 0 to x= 2.750 30 0.49499986 Table 1Program 3 September 2005 4 © 2005 by Carnegie Mellon University Numerical integration with Simpson’s rule Overview Numerical integration is the process of determining the area “under” some function. Numerical integration calculates this area by dividing it into vertical “strips” and summing their individual areas. The key is to minimize the error in this approximation. Simpson’s rule Simpson’s rule can be used to integrate a symmetrical statistical distribution function over a specified range (e.g., from 0 to some value x). 1. num_seg = initial number of segments, an even number 2. W = x/num_seg, the segment width 3. E = the acceptable error, e.g., 0.00001 4. Compute the integral value with the following equation. () ( ) ( ) ()⎥⎦⎤⎢⎣⎡+++=∑∑−=−=xFiWFiWFFWpsegnumisegnumi2_...6,4,21_...5,3,12403 5. Compute the integral value again, but this time with num_seg = num_seg*2. 6. If the difference between these two results is greater than E, double num_seg and compute the integral value again. Continue doing this until the difference between the last two results is less than E. The latest result is the answer. Continued on next page Integrating a functionProgram 3 September 2005 5 © 2005 by Carnegie Mellon University Numerical integration with Simpson’s rule, Continued A simple example Let’s look at a simple function, where F(x) = 2x. Note: This example is a triangle. The area of a triangle is ()( )heightbase21 ()()162328421== In this example, we can expand Simpson’s rule () ( ) ( ) ()⎥⎦⎤⎢⎣⎡+++=∑∑−=−=xFiWFiWFFWpsegnumisegnumi2_...6,4,21_...5,3,12403 to ()[]4)3(4)2(2)1(4)0(31FFFFFp ++++= and then substitute calculated values for the function F(x)= 2x ()[][]16348824880318)6(4)4(2)2(4)0(31==++++=++++=p F(x) = 2x num_seg = 4W = 4/4 = 1 x = 4Program 3 September 2005 6 © 2005 by Carnegie Mellon University The t distribution Overview The t distribution is a very important statistical tool. It is used instead of the normal distribution when the true value of the population variance is not known and must be estimated from a sample. The shape of the t distribution is dependent on the number of points in your dataset. As n gets large, the t distribution approaches the normal distribution. For lower values, it has a lower central “hump” and fatter “tails.” T probability density function-6 0 61525 Using the t distribution in the PSP In the PSP the t distribution is used in two ways. We use the t distribution to test the significance of a correlation. We also use the t distribution to calculate the prediction interval when using PROBE methods A and B. Continued on next pageProgram 3 September 2005 7 © 2005 by Carnegie Mellon University The t distribution, Continued T distribution function When numerically integrating the t distribution with Simpson’s rule, use the following function. ()()2/122/112*21)(+−⎟⎟⎠⎞⎜⎜⎝⎛+⎟⎠⎞⎜⎝⎛Γ⎟⎠⎞⎜⎝⎛+Γ=dofdofxdofdofdofxFπ where • dof = degrees of freedom • Γ is the gamma function The gamma function is )1()1()(−Γ−=Γ xxx , where • 1)1( =Γ • π=Γ )2/1( Continued on next pageProgram 3 September 2005 8 © 2005 by Carnegie Mellon University The t distribution, Continued An example of calculating gamma for an integer value )(xΓ for integer values is Γ(x)=x−1()!. 24!4)5( ==Γ An example of calculating gamma for a non-integer value ⎟⎠⎞⎜⎝⎛Γ=⎟⎠⎞⎜⎝⎛Γ272729 ⎟⎠⎞⎜⎝⎛Γ=⎟⎠⎞⎜⎝⎛Γ2525*272727 ⎟⎠⎞⎜⎝⎛Γ=⎟⎠⎞⎜⎝⎛Γ2323*25*272525*27 ⎟⎠⎞⎜⎝⎛Γ=⎟⎠⎞⎜⎝⎛Γ2121*23*25*272323*25*27 63173.11*21*23*25*272121*23*25*27==⎟⎠⎞⎜⎝⎛ΓπProgram 3 September 2005 9 © 2005 by Carnegie Mellon University An example An example In this example, we’ll calculate the values for the t distribution integral from 0 to x =1.1 with 9 degrees of freedom. 1. First we’ll set num_seg = 10 (any even number) 2. W = x/num_seg = 1.1/10 = 0.11 3. E = 0.00001 4. dof = 9 5. x = 1.1 6. Compute the integral value with the following equation. () ( ) ( ) ()⎥⎦⎤⎢⎣⎡+++=∑∑−=−=xFiWFiWFFWpsegnumisegnumi2_...6,4,21_...5,3,12403where ()()2/122/112*21)(+−⎟⎟⎠⎞⎜⎜⎝⎛+⎟⎠⎞⎜⎝⎛Γ⎟⎠⎞⎜⎝⎛+ΓdofdofxdofdofdofxFπ 7. We can solve the first part of the equation: ()388035.06317.11*3174.5242*212/1==⎟⎠⎞⎜⎝⎛Γ⎟⎠⎞⎜⎝⎛+Γdofdofdofπ The intermediate values for this are in the Table 2. i xi dofx21+ ⎟⎠⎞⎜⎝⎛+−⎟⎟⎠⎞⎜⎜⎝⎛+2121dofdofx()⎟⎠⎞⎜⎝⎛Γ⎟⎠⎞⎜⎝⎛+Γ2*212/1dofdofdofπ()ixF Multiplier terms 0 0 1 1 388035.00.38803 1 0.01423 1 0.11 1.00134 0.9933 388035.00.38544 4 0.05653 2 0.22 1.00538 0.97354 388035.00.37777 2 0.0277 3 0.33 1.0121 0.94164 388035.00.36539 4 0.05359 4 0.44 1.02151 0.89905 388035.00.34886 2 0.02558 5 0.55 1.03361 0.84765 388035.00.32892 4 0.04824 6 0.66 1.0484 0.78952 388035.00.30636 2 0.02247 7 0.77 1.06588 0.72688 388035.00.28205 4 0.04137 8 0.88 1.08604 0.66185 388035.00.25682 2 0.01883 9 0.99 1.1089 0.5964 388035.00.23142 4 0.03394 10 1.1


View Full Document

ODU CS 350 - Assignment Kit for Program 3

Download Assignment Kit for Program 3
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Assignment Kit for Program 3 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Assignment Kit for Program 3 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?