-
Notifications
You must be signed in to change notification settings - Fork 0
/
linfit.h
executable file
·26 lines (23 loc) · 896 Bytes
/
linfit.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
* @file linfit.h
* @brief A simple linear fit algorithm.
*
* This file contains the implementation of a simple linear fit algorithm. It provides a function to perform a linear fit on a set of data points.
* @date 11 Oct 2017
* @author obenomar
*/
#pragma once
#include <Eigen/Dense>
using Eigen::VectorXd;
/**
* @brief Performs a linear fit on a set of data points.
*
* This function takes two vectors, x and y, representing the x-coordinates and y-coordinates of the data points, and performs a linear fit to find the best-fit line.
*
* @param x The x-coordinates of the data points.
* @param y The y-coordinates of the data points.
* @return VectorXd A vector containing the slope and intercept of the best-fit line.
*
* @note The size of x and y must be the same.
*/
VectorXd linfit(const VectorXd& x, const VectorXd& y); // A more optimal way to perform a linear fit