Repository navigation
Expand file tree
/
Copy pathllsAnalysis.h
More file actions
60 lines (54 loc) · 2.21 KB
/
Copy pathllsAnalysis.h
File metadata and controls
60 lines (54 loc) · 2.21 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <fstream>
#include <sstream>
using namespace std;
/**
* Takes (x,y) coordinates and generates an output file with piecewise linear interpolation equations
* and a global linear least-squares approximation.
*
* @param x numeric vector representing x coordinates.
* @param y numeric vector representing y coordinates.
* @param fileName string representing the output file name.
*
*/
void llsAnalysisDriver(vector<double> x, vector<double> y, string fileName);
/**
* Generate a single linear least square equation.
*
* @param n numeric representing total pairs of (x,y) coordinates.
* @param totalX numeric representing total sum of all x coordinates.
* @param totalY numeric representing total sum of all y coordinates.
* @param totalX2 numeric representing total sum of each x coordinates to the second power (x^2).
* @param totalXY numeric representing total sum of each X * Y coordinates.
*
* @return a formatted linear least square equation.
*
*/
string getLinearLeastSquares(int n, double totalX, double totalY, double totalX2, double totalXY);
/**
* Retrieve the slope of (x,y) coordinates.
*
* @param n numeric representing total pairs of (x,y) coordinates.
* @param totalX numeric representing total sum of all x coordinates.
* @param totalY numeric representing total sum of all y coordinates.
* @param totalX2 numeric representing total sum of each x coordinates to the second power (x^2).
* @param totalXY numeric representing total sum of each X * Y coordinates.
*
* @return value of the slope
*
* @pre (cell1Id > 0 && cell1Id < 10) &&
* (cell2Id > 0 && cell2Id < 10) &&
* (cell3Id > 0 && cell3Id < 10)
*/
double getSlope(int n, double totalX, double totalY, double totalX2, double totalXY);
/**
* Retrieve the y-intercept of (x,y) coordinates.
*
* @param n numeric representing total pairs of (x,y) coordinates.
* @param totalY numeric representing total sum of all y coordinates.
* @param slope numeric representing the slop of a equation.
* @param totalX numeric representing total sum of all x coordinates.
*
* @return value of the y-intercept
*
*/
double getYintercept(int n, double totalY, double slope ,double totalX);