DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
SimpleLinearRegression.h
1
16
17
#pragma once
18
33
34
#if defined(SimpleLinearRegression_RECURSES)
35
#error Recursive header files inclusion detected in SimpleLinearRegression.h
36
#else
// defined(SimpleLinearRegression_RECURSES)
38
#define SimpleLinearRegression_RECURSES
39
40
#if !defined SimpleLinearRegression_h
42
#define SimpleLinearRegression_h
43
44
46
#include <iostream>
47
#include <vector>
49
50
51
namespace
DGtal
52
{
53
55
// class SimpleLinearRegression
57
73
class
SimpleLinearRegression
74
{
75
76
// ----------------------- Standard services ------------------------------
77
public
:
78
82
~SimpleLinearRegression
();
83
91
SimpleLinearRegression
(
double
eps_zero = 1e-8 );
92
96
void
clear
();
97
109
template
<
class
XIterator,
class
YIterator>
110
void
addSamples
( XIterator begin_x, XIterator end_x, YIterator begin_y );
111
122
void
addSample
(
const
double
x,
const
double
y );
123
130
bool
computeRegression
();
131
135
double
slope
()
const
;
136
137
141
double
intercept
()
const
;
142
150
double
estimateY
(
double
x )
const
;
151
156
double
estimateVariance
()
const
;
157
171
std::pair<double,double>
trustIntervalForY
(
const
double
x,
172
const
double
a )
const
;
173
174
181
void
setEpsilonZero
(
const
double
aEpsilonZero)
182
{
183
myEpsilonZero
= aEpsilonZero;
184
}
185
190
double
epsilonZero
()
const
191
{
192
return
myEpsilonZero
;
193
}
194
199
double
size
()
const
200
{
201
return
myN
;
202
}
203
204
// ----------------------- Interface --------------------------------------
205
public
:
206
211
void
selfDisplay
( std::ostream & that_stream )
const
;
216
bool
isValid
()
const
;
217
218
219
// ------------------------- Data ----------------------------------------
220
221
private
:
222
224
double
myEpsilonZero
;
225
227
unsigned
int
myN
;
228
230
std::vector<double>
myY
;
231
233
std::vector<double>
myX
;
234
237
double
myB
[ 2 ];
238
239
//Internal quantities.
240
std::vector<double>
myU
;
241
double
mySumX
;
242
double
mySumX2
;
243
double
mySumY
;
244
double
mySumXY
;
245
double
myD
;
246
double
myNormU2
;
247
248
// ------------------------- Hidden services ------------------------------
249
protected
:
250
251
private
:
252
258
SimpleLinearRegression
(
const
SimpleLinearRegression
& other );
259
266
SimpleLinearRegression
&
operator=
(
const
SimpleLinearRegression
& other );
267
268
// ------------------------- Internals ------------------------------------
269
private
:
270
271
272
};
273
280
std::ostream&
281
operator<<
( std::ostream & that_stream,
282
const
SimpleLinearRegression
& that_object_to_display );
283
284
285
}
// namespace ImaGene
286
287
289
// Includes inline functions/methods if necessary.
290
#include "DGtal/math/SimpleLinearRegression.ih"
291
292
// //
294
295
#endif
// !defined SimpleLinearRegression_h
296
297
#undef SimpleLinearRegression_RECURSES
298
#endif
// else defined(SimpleLinearRegression_RECURSES)
DGtal::SimpleLinearRegression
Description of class 'SimpleLinearRegression'.
Definition
SimpleLinearRegression.h:74
DGtal::SimpleLinearRegression::addSample
void addSample(const double x, const double y)
DGtal::SimpleLinearRegression::mySumX
double mySumX
Definition
SimpleLinearRegression.h:241
DGtal::SimpleLinearRegression::mySumX2
double mySumX2
Definition
SimpleLinearRegression.h:242
DGtal::SimpleLinearRegression::operator=
SimpleLinearRegression & operator=(const SimpleLinearRegression &other)
DGtal::SimpleLinearRegression::addSamples
void addSamples(XIterator begin_x, XIterator end_x, YIterator begin_y)
DGtal::SimpleLinearRegression::slope
double slope() const
DGtal::SimpleLinearRegression::estimateY
double estimateY(double x) const
DGtal::SimpleLinearRegression::~SimpleLinearRegression
~SimpleLinearRegression()
DGtal::SimpleLinearRegression::myU
std::vector< double > myU
Definition
SimpleLinearRegression.h:240
DGtal::SimpleLinearRegression::trustIntervalForY
std::pair< double, double > trustIntervalForY(const double x, const double a) const
DGtal::SimpleLinearRegression::clear
void clear()
DGtal::SimpleLinearRegression::setEpsilonZero
void setEpsilonZero(const double aEpsilonZero)
Definition
SimpleLinearRegression.h:181
DGtal::SimpleLinearRegression::myNormU2
double myNormU2
Definition
SimpleLinearRegression.h:246
DGtal::SimpleLinearRegression::mySumY
double mySumY
Definition
SimpleLinearRegression.h:243
DGtal::SimpleLinearRegression::intercept
double intercept() const
DGtal::SimpleLinearRegression::computeRegression
bool computeRegression()
DGtal::SimpleLinearRegression::mySumXY
double mySumXY
Definition
SimpleLinearRegression.h:244
DGtal::SimpleLinearRegression::myN
unsigned int myN
Number of samples.
Definition
SimpleLinearRegression.h:227
DGtal::SimpleLinearRegression::size
double size() const
Definition
SimpleLinearRegression.h:199
DGtal::SimpleLinearRegression::estimateVariance
double estimateVariance() const
DGtal::SimpleLinearRegression::myB
double myB[2]
Definition
SimpleLinearRegression.h:237
DGtal::SimpleLinearRegression::myEpsilonZero
double myEpsilonZero
Epsilon zero value.
Definition
SimpleLinearRegression.h:224
DGtal::SimpleLinearRegression::myX
std::vector< double > myX
Abscissa values of sample points.
Definition
SimpleLinearRegression.h:233
DGtal::SimpleLinearRegression::selfDisplay
void selfDisplay(std::ostream &that_stream) const
DGtal::SimpleLinearRegression::SimpleLinearRegression
SimpleLinearRegression(const SimpleLinearRegression &other)
DGtal::SimpleLinearRegression::SimpleLinearRegression
SimpleLinearRegression(double eps_zero=1e-8)
DGtal::SimpleLinearRegression::epsilonZero
double epsilonZero() const
Definition
SimpleLinearRegression.h:190
DGtal::SimpleLinearRegression::myY
std::vector< double > myY
Ordinate values of sample points.
Definition
SimpleLinearRegression.h:230
DGtal::SimpleLinearRegression::isValid
bool isValid() const
DGtal::SimpleLinearRegression::myD
double myD
Definition
SimpleLinearRegression.h:245
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
src
DGtal
math
SimpleLinearRegression.h
Generated on
for DGtal by
1.18.0