SlideShare ist ein Scribd-Unternehmen logo
1 von 4
Downloaden Sie, um offline zu lesen
CMPSC 201
Programming for Engineers with C++
Project 4
Assigned 7/24/14
Problem:
Suppose we have a set of data consisting of ordered pairs and we suspect
the x and y coordinates are related. It is natural to try to find the best line that
fits the data points. If we can find this line, then we can use it to make all sorts
of other predictions. In this project, we're going to use several functions to find
this line using a technique called least squares regression. The result will be
what we call the least squares regression line (or LSRL for short).
In order to do this, you'll be able to reuse some code you've already written
(improve it if necessary, of course), as the LSRL is more or less based on
statistical calculations we've already automated. You'll need to program one
new statistical computation called the correlation coefficient, denoted by r in
statistical symbols:
Once you have the correlation coefficient, you use it along with the sample
means and sample standard deviations of the x and y-coordinates to compute
the slope and y-intercept of your regression line via these formulas:
(Yes, it correct that b is used for slope here.)
By the way, this is another of those numerical methods that computers do so
well. While it's possible to compute an LSRL by hand, automating all of the
tedious calculations makes sense, and leaves us to spend our time interpreting
our results in a practical context.
Specifications:
You may work with one other person in class on this project if you wish. If you wish
to discuss the project with someone else, work with a partner. Otherwise, work
alone. There is to be NO collaboration between individuals/groups who are not
working as partners.
In this project, you must read the x- and y-coordinate pairs in from a data file of
unknown length. Each line in the file must contain both coordinates, separated
by whitespace, as shown in the sample data file on Angel. In addition, you must
use functions in this project, splitting the work up into smaller components and
reinforcing your skills with parameter passing and arrays.
You are required to create the following functions, and you must list them in
this order above the main program (no prototypes, please!):
Number (for
Reference)
Role Method's Objective Input Parameters Output Parameters
Returned
Values
1 Input
To read the input file,
line by line, and store
the x- and y-
coordinates in parallel
arrays
 none
 an array of x-
coordinates
read from the
file
 a parallel array
of y-
coordinates
read from the
file
 logical size of
the arrays
none
2 Process
To compute the sample
mean of a data set.
(Note that this one was
given as an example
and you should, by all
means, use it.)
 an array of
data
 logical size of
the array
 none
the sample
mean of the
data in the
array
3 Process
To compute the sample
standard deviation of a
data set. (Reuse code!
Consult Lab 8 for the
formula.)
 an array of
data
 logical size of
the array
 the sample
mean of the
data
 none
the sample
standard
deviation of
the data in the
array
4 Process
To compute the
correlation coefficient.
 an array of x-
coordinates
 none the correlation
coefficient of
read from the
file
 a parallel array
of y-
coordinates
read from the
file
 logical size of
the arrays
the input
arrays
5 Process
To compute the least-
squares regression line.
 an array of x-
coordinates
read from the
file
 a parallel array
of y-
coordinates
read from the
file
 logical size of
the arrays
 the y-intercept
of the line
 the slope of the
line
none
6 Output
To display a the
mathematical
representation of a line
to screen
 the y-intercept
of the line
 the slope of
the line
 none
none
Be sure to comment each function well. You should list the preconditions and
postconditions for each one (essentially what you assume about your inputs and
what your outputs will reflect).
You will also need a main program to drive this program. All computation
should be done in the six methods; the main program should be extremely
short. (I have fewer than a dozen lines of code.)
Testing your program:
This program will again be lengthy, so you should develop it incrementally, testing
each new part as you go. Use cout statements in your debugging when needed to
keep track of program flow and/or the value of variables. Sample test data files and
corresponding correct output will be released shortly for you to test your program
with.
Your program should provide the output that looks something like this:
Regression line: y = 1166.93 + -0.586788x
It will have no user input, so no prompts are needed. Any debug statements should
be commented out or removed before final submission. Your code should also
contain enough comments to an outside observer to follow its logic. In your final
submission, your program should open a file named "project_4_data.txt," which can
be assumed is in the same directory as the program.
Submission:
Upload your .cpp file from your project with the following filename (replacing
"abc123" and "def456" with your Penn State user Ids):
abc123_def456_project_4.cpp
Both partners should submit a copy of the program in their Angel account.
In a comment block at the top of your cpp file, please be sure to include the
following information: Name(s), Project number, Date assigned, Date due,
Description of program, Expected inputs, Expected outputs
Due date:
Submit by 11:55 PM on 8/8/14. After this time, the dropbox will no longer be
available. 10 bonus points will be awarded if submitted by 8/5/14.

Weitere ähnliche Inhalte

Was ist angesagt?

Introductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, QueueIntroductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, QueueGhaffar Khan
 
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...Umesh Kumar
 
Semantic scaffolds for pseudocode to-code generation (2020)
Semantic scaffolds for pseudocode to-code generation (2020)Semantic scaffolds for pseudocode to-code generation (2020)
Semantic scaffolds for pseudocode to-code generation (2020)Minhazul Arefin
 
algorithm and Pseudocode
algorithm and Pseudocodealgorithm and Pseudocode
algorithm and PseudocodeFabian Macuha
 
Abstract data types (adt) intro to data structure part 2
Abstract data types (adt)   intro to data structure part 2Abstract data types (adt)   intro to data structure part 2
Abstract data types (adt) intro to data structure part 2Self-Employed
 
3. Stack - Data Structures using C++ by Varsha Patil
3. Stack - Data Structures using C++ by Varsha Patil3. Stack - Data Structures using C++ by Varsha Patil
3. Stack - Data Structures using C++ by Varsha Patilwidespreadpromotion
 
Linear Model of Coregionalization
Linear Model of CoregionalizationLinear Model of Coregionalization
Linear Model of CoregionalizationEd Isaaks
 
FME Data Analytics, Lightning Talk_Ken Bragg - Safe Software FME World Tour 2013
FME Data Analytics, Lightning Talk_Ken Bragg - Safe Software FME World Tour 2013FME Data Analytics, Lightning Talk_Ken Bragg - Safe Software FME World Tour 2013
FME Data Analytics, Lightning Talk_Ken Bragg - Safe Software FME World Tour 2013IMGS
 
Data Structure
Data StructureData Structure
Data Structuresheraz1
 
Basic of Data Structure - Data Structure - Notes
Basic of Data Structure - Data Structure - NotesBasic of Data Structure - Data Structure - Notes
Basic of Data Structure - Data Structure - NotesOmprakash Chauhan
 
Lesson 21. Pattern 13. Data alignment
Lesson 21. Pattern 13. Data alignmentLesson 21. Pattern 13. Data alignment
Lesson 21. Pattern 13. Data alignmentPVS-Studio
 
358 33 powerpoint-slides_9-stacks-queues_chapter-9
358 33 powerpoint-slides_9-stacks-queues_chapter-9358 33 powerpoint-slides_9-stacks-queues_chapter-9
358 33 powerpoint-slides_9-stacks-queues_chapter-9sumitbardhan
 
My presentation
My presentationMy presentation
My presentationSaifur13
 

Was ist angesagt? (19)

Introductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, QueueIntroductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, Queue
 
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
 
Data visualization with R
Data visualization with RData visualization with R
Data visualization with R
 
Method parameters in c#
Method parameters in c#Method parameters in c#
Method parameters in c#
 
Semantic scaffolds for pseudocode to-code generation (2020)
Semantic scaffolds for pseudocode to-code generation (2020)Semantic scaffolds for pseudocode to-code generation (2020)
Semantic scaffolds for pseudocode to-code generation (2020)
 
algorithm and Pseudocode
algorithm and Pseudocodealgorithm and Pseudocode
algorithm and Pseudocode
 
Abstract data types (adt) intro to data structure part 2
Abstract data types (adt)   intro to data structure part 2Abstract data types (adt)   intro to data structure part 2
Abstract data types (adt) intro to data structure part 2
 
3. Stack - Data Structures using C++ by Varsha Patil
3. Stack - Data Structures using C++ by Varsha Patil3. Stack - Data Structures using C++ by Varsha Patil
3. Stack - Data Structures using C++ by Varsha Patil
 
Ch13
Ch13Ch13
Ch13
 
Getting started with R
Getting started with RGetting started with R
Getting started with R
 
Linear Model of Coregionalization
Linear Model of CoregionalizationLinear Model of Coregionalization
Linear Model of Coregionalization
 
FME Data Analytics, Lightning Talk_Ken Bragg - Safe Software FME World Tour 2013
FME Data Analytics, Lightning Talk_Ken Bragg - Safe Software FME World Tour 2013FME Data Analytics, Lightning Talk_Ken Bragg - Safe Software FME World Tour 2013
FME Data Analytics, Lightning Talk_Ken Bragg - Safe Software FME World Tour 2013
 
Data Structure
Data StructureData Structure
Data Structure
 
Getting started to r
Getting  started  to rGetting  started  to r
Getting started to r
 
Basic of Data Structure - Data Structure - Notes
Basic of Data Structure - Data Structure - NotesBasic of Data Structure - Data Structure - Notes
Basic of Data Structure - Data Structure - Notes
 
Lesson 1 overview
Lesson 1   overviewLesson 1   overview
Lesson 1 overview
 
Lesson 21. Pattern 13. Data alignment
Lesson 21. Pattern 13. Data alignmentLesson 21. Pattern 13. Data alignment
Lesson 21. Pattern 13. Data alignment
 
358 33 powerpoint-slides_9-stacks-queues_chapter-9
358 33 powerpoint-slides_9-stacks-queues_chapter-9358 33 powerpoint-slides_9-stacks-queues_chapter-9
358 33 powerpoint-slides_9-stacks-queues_chapter-9
 
My presentation
My presentationMy presentation
My presentation
 

Ähnlich wie Project

R programming slides
R  programming slidesR  programming slides
R programming slidesPankaj Saini
 
Program 1 – CS 344This assignment asks you to write a bash.docx
Program 1 – CS 344This assignment asks you to write a bash.docxProgram 1 – CS 344This assignment asks you to write a bash.docx
Program 1 – CS 344This assignment asks you to write a bash.docxwkyra78
 
Java conceptual learning material
Java conceptual learning materialJava conceptual learning material
Java conceptual learning materialArthyR3
 
Compiler Construction for DLX Processor
Compiler Construction for DLX Processor Compiler Construction for DLX Processor
Compiler Construction for DLX Processor Soham Kulkarni
 
Educational Objectives After successfully completing this assignmen.pdf
Educational Objectives After successfully completing this assignmen.pdfEducational Objectives After successfully completing this assignmen.pdf
Educational Objectives After successfully completing this assignmen.pdfrajeshjangid1865
 
Documents.pub sigmaplot 13-smit-principal-components-analysis-principal-compo...
Documents.pub sigmaplot 13-smit-principal-components-analysis-principal-compo...Documents.pub sigmaplot 13-smit-principal-components-analysis-principal-compo...
Documents.pub sigmaplot 13-smit-principal-components-analysis-principal-compo...Martin Magu
 
educational course/tutorialoutlet.com
educational course/tutorialoutlet.comeducational course/tutorialoutlet.com
educational course/tutorialoutlet.comjorge0043
 
Excel analysis assignment this is an independent assignment me
Excel analysis assignment this is an independent assignment meExcel analysis assignment this is an independent assignment me
Excel analysis assignment this is an independent assignment mejoney4
 
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docxBTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docxAASTHA76
 
R-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfR-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfKabilaArun
 
R-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfR-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfattalurilalitha
 
Unraveling The Meaning From COVID-19 Dataset Using Python – A Tutorial for be...
Unraveling The Meaning From COVID-19 Dataset Using Python – A Tutorial for be...Unraveling The Meaning From COVID-19 Dataset Using Python – A Tutorial for be...
Unraveling The Meaning From COVID-19 Dataset Using Python – A Tutorial for be...Kavika Roy
 
CS 23001 Computer Science II Data Structures & AbstractionPro.docx
CS 23001 Computer Science II Data Structures & AbstractionPro.docxCS 23001 Computer Science II Data Structures & AbstractionPro.docx
CS 23001 Computer Science II Data Structures & AbstractionPro.docxfaithxdunce63732
 
C interview-questions-techpreparation
C interview-questions-techpreparationC interview-questions-techpreparation
C interview-questions-techpreparationKushaal Singla
 
Data visualization using R
Data visualization using RData visualization using R
Data visualization using RUmmiya Mohammedi
 
Data structure and algorithm.
Data structure and algorithm. Data structure and algorithm.
Data structure and algorithm. Abdul salam
 
(4) cpp automatic arrays_pointers_c-strings_exercises
(4) cpp automatic arrays_pointers_c-strings_exercises(4) cpp automatic arrays_pointers_c-strings_exercises
(4) cpp automatic arrays_pointers_c-strings_exercisesNico Ludwig
 

Ähnlich wie Project (20)

R programming slides
R  programming slidesR  programming slides
R programming slides
 
Program 1 – CS 344This assignment asks you to write a bash.docx
Program 1 – CS 344This assignment asks you to write a bash.docxProgram 1 – CS 344This assignment asks you to write a bash.docx
Program 1 – CS 344This assignment asks you to write a bash.docx
 
Java conceptual learning material
Java conceptual learning materialJava conceptual learning material
Java conceptual learning material
 
Compiler Construction for DLX Processor
Compiler Construction for DLX Processor Compiler Construction for DLX Processor
Compiler Construction for DLX Processor
 
Educational Objectives After successfully completing this assignmen.pdf
Educational Objectives After successfully completing this assignmen.pdfEducational Objectives After successfully completing this assignmen.pdf
Educational Objectives After successfully completing this assignmen.pdf
 
Documents.pub sigmaplot 13-smit-principal-components-analysis-principal-compo...
Documents.pub sigmaplot 13-smit-principal-components-analysis-principal-compo...Documents.pub sigmaplot 13-smit-principal-components-analysis-principal-compo...
Documents.pub sigmaplot 13-smit-principal-components-analysis-principal-compo...
 
educational course/tutorialoutlet.com
educational course/tutorialoutlet.comeducational course/tutorialoutlet.com
educational course/tutorialoutlet.com
 
Excel analysis assignment this is an independent assignment me
Excel analysis assignment this is an independent assignment meExcel analysis assignment this is an independent assignment me
Excel analysis assignment this is an independent assignment me
 
Programming
ProgrammingProgramming
Programming
 
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docxBTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
 
R-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfR-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdf
 
R-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfR-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdf
 
R-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdfR-Language-Lab-Manual-lab-1.pdf
R-Language-Lab-Manual-lab-1.pdf
 
Unraveling The Meaning From COVID-19 Dataset Using Python – A Tutorial for be...
Unraveling The Meaning From COVID-19 Dataset Using Python – A Tutorial for be...Unraveling The Meaning From COVID-19 Dataset Using Python – A Tutorial for be...
Unraveling The Meaning From COVID-19 Dataset Using Python – A Tutorial for be...
 
CS 23001 Computer Science II Data Structures & AbstractionPro.docx
CS 23001 Computer Science II Data Structures & AbstractionPro.docxCS 23001 Computer Science II Data Structures & AbstractionPro.docx
CS 23001 Computer Science II Data Structures & AbstractionPro.docx
 
C interview-questions-techpreparation
C interview-questions-techpreparationC interview-questions-techpreparation
C interview-questions-techpreparation
 
Data visualization using R
Data visualization using RData visualization using R
Data visualization using R
 
Data structure and algorithm.
Data structure and algorithm. Data structure and algorithm.
Data structure and algorithm.
 
(4) cpp automatic arrays_pointers_c-strings_exercises
(4) cpp automatic arrays_pointers_c-strings_exercises(4) cpp automatic arrays_pointers_c-strings_exercises
(4) cpp automatic arrays_pointers_c-strings_exercises
 
final
finalfinal
final
 

Kürzlich hochgeladen

How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 

Kürzlich hochgeladen (20)

How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 

Project

  • 1. CMPSC 201 Programming for Engineers with C++ Project 4 Assigned 7/24/14 Problem: Suppose we have a set of data consisting of ordered pairs and we suspect the x and y coordinates are related. It is natural to try to find the best line that fits the data points. If we can find this line, then we can use it to make all sorts of other predictions. In this project, we're going to use several functions to find this line using a technique called least squares regression. The result will be what we call the least squares regression line (or LSRL for short). In order to do this, you'll be able to reuse some code you've already written (improve it if necessary, of course), as the LSRL is more or less based on statistical calculations we've already automated. You'll need to program one new statistical computation called the correlation coefficient, denoted by r in statistical symbols: Once you have the correlation coefficient, you use it along with the sample means and sample standard deviations of the x and y-coordinates to compute the slope and y-intercept of your regression line via these formulas: (Yes, it correct that b is used for slope here.) By the way, this is another of those numerical methods that computers do so well. While it's possible to compute an LSRL by hand, automating all of the
  • 2. tedious calculations makes sense, and leaves us to spend our time interpreting our results in a practical context. Specifications: You may work with one other person in class on this project if you wish. If you wish to discuss the project with someone else, work with a partner. Otherwise, work alone. There is to be NO collaboration between individuals/groups who are not working as partners. In this project, you must read the x- and y-coordinate pairs in from a data file of unknown length. Each line in the file must contain both coordinates, separated by whitespace, as shown in the sample data file on Angel. In addition, you must use functions in this project, splitting the work up into smaller components and reinforcing your skills with parameter passing and arrays. You are required to create the following functions, and you must list them in this order above the main program (no prototypes, please!): Number (for Reference) Role Method's Objective Input Parameters Output Parameters Returned Values 1 Input To read the input file, line by line, and store the x- and y- coordinates in parallel arrays  none  an array of x- coordinates read from the file  a parallel array of y- coordinates read from the file  logical size of the arrays none 2 Process To compute the sample mean of a data set. (Note that this one was given as an example and you should, by all means, use it.)  an array of data  logical size of the array  none the sample mean of the data in the array 3 Process To compute the sample standard deviation of a data set. (Reuse code! Consult Lab 8 for the formula.)  an array of data  logical size of the array  the sample mean of the data  none the sample standard deviation of the data in the array 4 Process To compute the correlation coefficient.  an array of x- coordinates  none the correlation coefficient of
  • 3. read from the file  a parallel array of y- coordinates read from the file  logical size of the arrays the input arrays 5 Process To compute the least- squares regression line.  an array of x- coordinates read from the file  a parallel array of y- coordinates read from the file  logical size of the arrays  the y-intercept of the line  the slope of the line none 6 Output To display a the mathematical representation of a line to screen  the y-intercept of the line  the slope of the line  none none Be sure to comment each function well. You should list the preconditions and postconditions for each one (essentially what you assume about your inputs and what your outputs will reflect). You will also need a main program to drive this program. All computation should be done in the six methods; the main program should be extremely short. (I have fewer than a dozen lines of code.) Testing your program: This program will again be lengthy, so you should develop it incrementally, testing each new part as you go. Use cout statements in your debugging when needed to keep track of program flow and/or the value of variables. Sample test data files and corresponding correct output will be released shortly for you to test your program with. Your program should provide the output that looks something like this: Regression line: y = 1166.93 + -0.586788x It will have no user input, so no prompts are needed. Any debug statements should be commented out or removed before final submission. Your code should also contain enough comments to an outside observer to follow its logic. In your final
  • 4. submission, your program should open a file named "project_4_data.txt," which can be assumed is in the same directory as the program. Submission: Upload your .cpp file from your project with the following filename (replacing "abc123" and "def456" with your Penn State user Ids): abc123_def456_project_4.cpp Both partners should submit a copy of the program in their Angel account. In a comment block at the top of your cpp file, please be sure to include the following information: Name(s), Project number, Date assigned, Date due, Description of program, Expected inputs, Expected outputs Due date: Submit by 11:55 PM on 8/8/14. After this time, the dropbox will no longer be available. 10 bonus points will be awarded if submitted by 8/5/14.