Skip to content

ajlekcahdp4/LSM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Linux

license GH stars GH pull-requests GH issues

Least Square Method Calculation

table of contents:

How to clone

To clone this repository run:

git clone https://github.com/ajlekcahdp4/LSM.git
cd LSM

Dependencies

You can install gnuplot by apt / apt-get:

sudo apt install gnuplot

Or by pacman (On Arch and Manjaro linux):

sudo pacman -S gnuplot

You can install cmake by apt / apt-get:

sudo apt install cmake

Or by pacman (On Arch and Manjaro linux):

sudo pacman -S cmake

How to use

Use as a library

In development...

You can also use this library as a complete program for least squares method calculation and graph plotting

Using my main file. In this case:

To compile this program run:

cmake .
make

And then to run it use:

./calc

The program will ask you about type of aproximation (managed linear, exponential and any-degrees polinomial), input file name, output file name, abscissa axis label, ordinate axis label and degree of the polinom (in polinomial approximation case)

Input files format

You have to write measured points in a file this way:

  1. The decimal separator should be a dot, not a comma.
  2. Write abscissa and ordinate values in columns like this

example of the input file

Points near y = x^3 line (for example)
  • In this example was used this points:
Point number X Y
1 1.0 1.2
2 2.0 9.0
3 3.0 26.0
4 4.0 67.0
5 5.0 116.0

output format

After the program is completed, information about the calculation performed using the least squares method will be written to the file that you specified as output.

  • If the file did not exist, it will be created

The output file will look like this:

  • example of the output file for polinomial approximation:

example of the output file

  • example of the output file for linear approximation:

example of the output file

  • example of the output file for exponential approximation:

example of the output file

And also you will get the graph of your approximation:

  • example of the polinomial graph:

example of the polinomial graph

  • example of the exponential graph:

example of the exponential graph

  • example of the linear graph:

example of the linear graph

  • My program also can managed hight-levels polinoms. In the example down below I approximate this points:
X Y
1.0 2.0
2.0 2.0
3.0 3.0
4.0 5.0
5.0 5.0
6.0 6.0
7.0 8.0
8.0 9.0
9.0 10.0
10.0 12.0
11.0 10.0
12.0 12.0
13.0 12.0
14.0 14.0
15.0 17.0
16.0 16.0
17.0 18.0
18.0 17.0
19.0 19.0
20.0 19.0

with the 8-degree polinom.

example of the hight-degree polinom

Feedback

  • If you faced some bugs with this program - please, create a bug report in the issues and I'll try to help you.

  • If you have an idea how to improve this project - please, write it in issue or fork this repository, write code and create pull request.

If you found my program interesting or usefull please Give me a star 🌟