Skip to content

zoumson/CurveFitting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

LinkedIn

Curve fitting

curve

Table of Contents
  1. About The Project
  2. Files Structure
  3. Getting Started
  4. Usage
  5. Roadmap
  6. Contributing
  7. License
  8. Contact
  9. Acknowledgements

About The Project

In regression analysis, curve fitting is the process of specifying the model that provides the best fit to the specific curves in your dataset. Curved relationships between variables are not as straightforward to fit and interpret as linear relationships. For linear relationships, as you increase the independent variable by one unit, the mean of the dependent variable always changes by a specific amount. This relationship holds true regardless of where you are in the observation space.

Unfortunately, the real world isn’t always nice and neat like this. Sometimes your data have curved relationships between variables. In a curved relationship, the change in the dependent variable associated with a one unit shift in the independent variable varies based on the location in the observation space. In other words, the effect of the independent variable is not a constant value. Most curves used to fit experimental data are non-linear. In this project two c++ frameworks, namely, ceres and g2o are used to estimate the parameter of the model given a set of experimenal data.

The fitting model is as follows:

Built With



File Structure

Folders

Entire Files Structure

.
├── CMakeLists.txt
├── include
│   ├── CeresCost.h
│   └── CommonCurve.h
├── README.md
└── src
    ├── ceres
    │   ├── CMakeLists.txt
    │   ├── cmake_modules
    │   │   └── CeresConfig.cmake.in
    │   └── demoCeres.cpp
    └── g2o
        ├── CMakeLists.txt
        ├── cmake_modules
        │   └── FindG2O.cmake
        └── demoG2O.cpp

6 directories, 10 files


Getting Started

This is a sample code of how you may use g2o and ceres to perform curve fitting. To get a local copy up and running follow these simple steps.

Prerequisites

This is an example of how to list things you need to use the software and how to install them.

  • cmake
    sudo apt-get install cmake
  • eigen
sudo apt-get install -y libeigen3-dev
  • suitesparse
sudo apt-get install -y libsuitesparse-dev
  • qt
sudo apt-get install -y qtdeclarative5-dev qt5-qmake libqglviewer-dev
  • g2o
sudo su 
cd /opt && mkdir g2oInstall && cd g2oInstall \
&& git clone https://github.com/RainerKuemmerle/g2o.git \
&& cd g2o && mkidr build && cd build && cmake .. \
&& make -j4 && make install
  • ceres
sudo apt-get install libgoogle-glog-dev libatlas-base-dev && \
&& cd /opt && mkdir ceresInstall && cd ceresInstall \
&& git clone https://github.com/ceres-solver/ceres-solver.git \
&& cd ceres-solver && mkdir build && cd build && cmake .. \
&& make -j4 && make install
  • opencv4
sudo su
git clone https://github.com/zoumson/OpencvInstall.git     \
&& cd OpencvInstall && chmod +x install.sh && ./install.sh
  • Boost
  sudo apt-get install libboost-all-dev

Installation

  1. Clone the repo
    git clone https://github.com/zoumson/CurveFitting.git
  2. Go to the project directory source
    cd CurveFitting
  3. Create empty directories build, and bin
    mkdir build &&  mkdir bin 
  4. Generate the exectutables and move them to bin
    cd build && cmake .. && make -j4 && cd ..

Usage

  1. Command line options
Usage: options_description [options]
Allowed options:
  -h [ --help ]                         produce help message
  -a [ --first ] arg                    first parameter
  -b [ --second ] arg                   second parameter
  -c [ --third ] arg                    third parameter
  -n [ --number ] [=arg(=500)] (=100)   number of data
  -i [ --iteration ] [=arg(=200)] (=100)
                                        number of iterations
  -s [ --noise ] [=arg(=5)] (=1)        noise added
  1. Run with ceres
./bin/demoCeres -a 1 -b 1 -c 1
  1. Sample Data generated as 29_06_2021_13_46_37_readDataCeres.txt in directory result
  2. Parameter for the model saved in 29_06_2021_13_46_37_parametersCeres.txt
Estimated a,b,c =0.660982 1.5863 -0.190824
  1. Run with g2o
./bin/demoG2O -a 1 -b 1 -c 1
  1. Sample Data generated as 29_06_2021_13_49_32_readDataG2O.txt in directory result
  2. Parameter for the model saved in 29_06_2021_13_46_37_parametersCeres.txt
estimated model a, b, c: 0.656489  1.59246 -0.19271
  1. Back to the initial file structure configuration
    rm -r bin build result

Roadmap

All the headers files are well docummented, read through the comments

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Adama Zouma - - stargue49@gmail.com

Project Link: https://github.com/zoumson/CurveFitting

Acknowledgements