Skip to content

Python program that calculates linear regression line and Pearson correlation coefficient for a data set.

Notifications You must be signed in to change notification settings

sadiqui/linear-stat-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Linear Stats

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

Usage

  1. Make sure Python is installed on your system (version 3.6 or higher).
  2. Install the required dependencies:
pip install numpy scipy
  1. run the program, using:
python3 app.py data.txt

Testing

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!

Concepts

Linear Regression Line

linear/concept linear/formula

Pearson Correlation Coefficient

linear/concept linear/formula

About

Python program that calculates linear regression line and Pearson correlation coefficient for a data set.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages