#include <linlsq.h>
List of all members.
Detailed Description
Definition at line 26 of file linlsq.h.
Constructor & Destructor Documentation
Member Function Documentation
void LLSQ::add |
( |
double |
x, |
|
|
double |
y |
|
) |
| |
Definition at line 50 of file linlsq.cpp.
{
total_weight++;
sigx += x;
sigy += y;
sigxx += x * x;
sigxy += x * y;
sigyy += y * y;
}
void LLSQ::add |
( |
double |
x, |
|
|
double |
y, |
|
|
double |
weight |
|
) |
| |
Definition at line 59 of file linlsq.cpp.
{
total_weight += weight;
sigx += x * weight;
sigy += y * weight;
sigxx += x * x * weight;
sigxy += x * y * weight;
sigyy += y * y * weight;
}
void LLSQ::add |
( |
const LLSQ & |
other | ) |
|
Definition at line 68 of file linlsq.cpp.
{
total_weight += other.total_weight;
sigx += other.sigx;
sigy += other.sigy;
sigxx += other.sigxx;
sigxy += other.sigxy;
sigyy += other.sigyy;
}
double LLSQ::c |
( |
double |
m | ) |
const |
Definition at line 118 of file linlsq.cpp.
{
if (total_weight > 0.0)
return (sigy - m * sigx) / total_weight;
else
return 0;
}
Definition at line 34 of file linlsq.cpp.
{
total_weight = 0.0;
sigx = 0.0;
sigy = 0.0;
sigxx = 0.0;
sigxy = 0.0;
sigyy = 0.0;
}
inT32 LLSQ::count |
( |
| ) |
const [inline] |
Definition at line 41 of file linlsq.h.
{
return static_cast<int>(total_weight + 0.5);
}
double LLSQ::covariance |
( |
| ) |
const [inline] |
Definition at line 60 of file linlsq.h.
{
if (total_weight > 0.0)
return (sigxy - sigx * sigy / total_weight) / total_weight;
else
return 0.0;
}
FCOORD LLSQ::mean_point |
( |
| ) |
const |
Definition at line 168 of file linlsq.cpp.
{
if (total_weight > 0.0) {
return FCOORD(sigx / total_weight, sigy / total_weight);
} else {
return FCOORD(0.0f, 0.0f);
}
}
double LLSQ::pearson |
( |
| ) |
const |
Definition at line 155 of file linlsq.cpp.
{
double r = 0.0;
double covar = covariance();
if (covar != 0.0) {
double var_product = x_variance() * y_variance();
if (var_product > 0.0)
r = covar / sqrt(var_product);
}
return r;
}
void LLSQ::remove |
( |
double |
x, |
|
|
double |
y |
|
) |
| |
Definition at line 84 of file linlsq.cpp.
{
if (total_weight <= 0.0)
EMPTY_LLSQ.error("LLSQ::remove", ABORT, NULL);
total_weight--;
sigx -= x;
sigy -= y;
sigxx -= x * x;
sigxy -= x * y;
sigyy -= y * y;
}
double LLSQ::rms |
( |
double |
m, |
|
|
double |
c |
|
) |
| const |
Definition at line 132 of file linlsq.cpp.
{
double error;
if (total_weight > 0) {
error = sigyy + m * (m * sigxx + 2 * (c * sigx - sigxy)) + c *
(total_weight * c - 2 * sigy);
if (error >= 0)
error = sqrt(error / total_weight);
else
error = 0;
} else {
error = 0;
}
return error;
}
FCOORD LLSQ::vector_fit |
( |
| ) |
const |
Definition at line 182 of file linlsq.cpp.
{
double x_var = x_variance();
double y_var = y_variance();
double covar = covariance();
FCOORD result;
if (x_var >= y_var) {
if (x_var == 0.0)
return FCOORD(0.0f, 0.0f);
result.set_x(x_var / sqrt(x_var * x_var + covar * covar));
result.set_y(sqrt(1.0 - result.x() * result.x()));
} else {
result.set_y(y_var / sqrt(y_var * y_var + covar * covar));
result.set_x(sqrt(1.0 - result.y() * result.y()));
}
if (covar < 0.0)
result.set_y(-result.y());
return result;
}
double LLSQ::x_variance |
( |
| ) |
const [inline] |
Definition at line 66 of file linlsq.h.
{
if (total_weight > 0.0)
return (sigxx - sigx * sigx / total_weight) / total_weight;
else
return 0.0;
}
double LLSQ::y_variance |
( |
| ) |
const [inline] |
Definition at line 72 of file linlsq.h.
{
if (total_weight > 0.0)
return (sigyy - sigy * sigy / total_weight) / total_weight;
else
return 0.0;
}
The documentation for this class was generated from the following files: