ajlekcahdp4 / LSM

least square method calculation
MIT License
1 stars 0 forks source link
approximation approximation-method c graph-plot labs least-squares-approximation

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

1) gnuplot:

You can install gnuplot by apt / apt-get:

sudo apt install gnuplot

Or by pacman (On Arch and Manjaro linux):

sudo pacman -S gnuplot

2) cmake

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)
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.

The output file will look like this:

And also you will get the graph of your approximation:

with the 8-degree polinom.

example of the hight-degree polinom

Feedback

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