This Python program reads data from a file and calculates two key statistics: the Linear Regression Line and the Pearson Correlation Coefficient. The data file contains one value per line, which represents the y-values of a graph, while the x-values are the line numbers (starting from 0).
The program expects the data to be provided in a file where each line contains a single number, like this:
189
113
121
114
145
110
...
Example of the program output:
Linear Regression Line: y = 3.456789x + 1.234567
Pearson Correlation Coefficient: 0.9876543210
- Make sure Python is installed on your system (version 3.6 or higher).
- Install the required dependencies:
pip install numpy scipy
- run the program, using:
python3 app.py data.txt
To test the program, run ./bin/linear-stats
followed by python3 app.py data.txt
, and compare the results of the tester with my program. The bin program modifies data.txt
each time it runs, so feel free to test multiple times. Happy testing!