EECS 280 Project 1: Statistics
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
EECS 280 Project 1: Statistics
|
Due 8pm ET Wed Sep 13, 2023. This is an individual project. Fall 2023 release. Introduction |
Write a program to analyze the data from a study about how couples meet and stay together.
The learning goals of this project include the C++ Machine Model, Procedural Abstraction, and
Testing & Debugging. It’s also a chance to get used to the C++ tool chain and review your 100-level programming skills.
When you’redone, you’ll have a program that analyzes data from the research study. For example, we can see that the median survey respondent was 47 years old ( ppage column).
$ ./main .exe
enter a filename
HCMST_ver_3 .04 .tsv
enter a column name
ppage
reading column ppage from HCMST_ver_3 .04 .tsv
Summary (value: frequency)
19 : 33
20 : 76
21 : 65
...
95 : 1
count = 4002
sum = 190134
mean = 47 .5097
stdev = 16 .4971
median = 47 |
mode = 56
min = 19
0th percentile = 19
25th percentile = 34 .25
50th percentile = 47
75th percentile = 59
100th percentile = 95
Setup
Set up your project in your visual debugger. We recommend VS Code because it’s easier to use. Many people use Visual Studio (Windows) or XCode (macOS).
During setup, name your project p1-stats . Use this starter files link:
https://eecs280staff.github.io/p1-stats/starter-files.tar.gz
After you’redone, you should have a folder with starter files that looks like this.
1 $ ls 2 Makefile main_test .out .correct p1_library .hpp stats_public_test .cpp 3 main .cpp main_test_data .tsv stats .cpp stats_tests .cpp 4 main_test .in p1_library .cpp stats .hpp |
Here’s a short description of each starter file.
File |
Description |
|
|
Helper commands for building and submitting |
|
|
Main statistical analysis program |
|
|
Inputs for main program |
|
|
Correct output of main program |
|
|
Data file for main program |
|
|
Provided code implementations |
|
|
Provided code function prototypes |
|
|
Function implementations for statistics library |
|
|
Tests for statistics library |
|
|
A “does my code compile” test case |
File |
Description |
||
|
|
Function prototypes for statistics library |
Δ Pitfall: Make sure you have set up your visual debugger before continuing.
Statistics Library
Write a general purpose statistics library.
If you’re new to the C++ Standard Template Library (STL) vector library, checkout our STL Vector examples. C++ vectors are similar to C/C++ arrays, Java arrays, or Python lists.
Write implementations in stats .cpp for the functions declared in stats .hpp .
Run the public stats tests. It’s just a compile check.
1 $ make stats_public_test .exe 2 $ ./stats_public_test .exe |
||
Write tests for the stats functions in stats_tests .cpp . We recommend writing one test, then implementing the function. Repeat for each function. This is called test-driven development. There’s more info in the testing section. |
||
1 |
$ |
make stats_tests .exe |
2 |
$ |
./stats_tests .exe |
Δ Pitfall: If you’re getting errors like this, checkout the Comparisons tutorial.
Setup
Configure your IDE to debug either the public tests or your own tests.
|
Public tests |
Your own tests |
VS Code (macOS) |
Set program name to: ${workspaceFolder}/stats_public_test .exe |
Set program name to: ${workspaceFolder}/stats_te |
VS Code (Windows) |
Set program name to: ${workspaceFolder}/stats_public_test .exe |
Set program name to: ${workspaceFolder}/stats_te |
XCode |
Include compile sources: stats_public_test .cpp , stats .cpp , p1_library .cpp |
Include compile sources: stats_tests .cpp , stats .cpp p1_library .cpp |
Visual Studio |
Exclude files from the build:
Include stats_public_test .cpp Exclude main .cpp , stats_tests .cpp |
Exclude files from the build:
Include stats_tests .cpp Exclude main .cpp , stats_public_test .cpp |
|
Add a new file stats .cpp . Add a function stub for each prototype in stats .hpp . This will make the program compile.
stats .cpp |
1 // stats.cpp
2 #include "stats .hpp"
3 #include "p1_library .hpp"
4 #include
5 #include
6 #include
7
8 using namespace std;
9
10 vector<pair<double, int> > summarize(vector<double> v) {
11 assert(false);
12 }
13
14 int count(vector<double> v) {
15 assert(false);
17
18 double sum(vector<double> v) {
19 assert(false);
20 }
21
22 double mean(vector<double> v) {
23 assert(false);
24 }
25
26 double median(vector<double> v) {
27 assert(false);
28 }
29
2023-09-15