To clone this repository run:
git clone https://github.com/ajlekcahdp4/LSM.git
cd LSM
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
- If you face some problem with
libQt5Core.so.5
use this reccomendations.
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
You can also use this library as a complete program for least squares method calculation and graph plotting
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)
You have to write measured points in a file this way:
- The decimal separator should be a dot, not a comma.
- Write abscissa and ordinate values in columns like this
- 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 |
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 for linear approximation:
- example of the output file for exponential approximation:
And also you will get the graph of your approximation:
- example of the polinomial graph:
- example of the exponential 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.