#include <linalg.h>
|
static double | EvaluateFit (const TFltIntKdV &data, const double A, const double B) |
|
static void | EvaluateFit (const TFltIntKdV &data, const double A, const double B, double &J, double &JA, double &JB) |
|
static void | EvaluateFit (const TFltIntKdV &data, const double A, const double B, const double U, const double V, const double lambda, double &J, double &JJ, double &JJJ) |
|
Definition at line 454 of file linalg.h.
TSigmoid::TSigmoid |
( |
const double & |
A_, |
|
|
const double & |
B_ |
|
) |
| |
|
inline |
Definition at line 1548 of file linalg.cpp.
1558 double minProj = data[0].Key, maxProj = data[0].Key;
1559 {
for (
int i = 1; i < data.
Len(); i++) {
1560 double zi = data[i].Key;
if (zi < minProj) minProj = zi;
if (zi > maxProj) maxProj = zi; }}
1562 A = 1.0;
B = 0.5 * (minProj + maxProj);
1563 double bestJ = 0.0, bestA = 0.0, bestB = 0.0, lambda = 1.0;
1564 for (
int nIter = 0; nIter < 50; nIter++)
1567 if (nIter == 0 || J < bestJ) { bestJ = J; bestA =
A; bestB =
B; }
1571 if (norm < 1e-10)
break;
1577 while (lambda > 1e-5) {
1578 lambda = 0.5 * lambda;
1583 while (lambda < 1e5) {
1584 double lambda2 = 2 * lambda;
1587 if (Jc2 > Jc)
break;
1588 lambda = lambda2; Jc = Jc2; } }
1590 A += cl * lambda * JA / norm;
B += cl * lambda * JB / norm;
1593 A = bestA;
B = bestB;
static double EvaluateFit(const TFltIntKdV &data, const double A, const double B)
TSizeTy Len() const
Returns the number of elements in the vector.
static double Sqr(const double &x)
TSigmoid::TSigmoid |
( |
TSIn & |
SIn | ) |
|
|
inline |
double TSigmoid::EvaluateFit |
( |
const TFltIntKdV & |
data, |
|
|
const double |
A, |
|
|
const double |
B |
|
) |
| |
|
staticprivate |
Definition at line 1490 of file linalg.cpp.
1493 for (
int i = 0; i < data.
Len(); i++)
1495 double zi = data[i].Key;
int yi = data[i].Dat;
1496 double e = exp(-
A * zi +
B);
1497 double denum = 1.0 + e;
1498 double prob = (yi > 0) ? (1.0 / denum) : (e / denum);
1499 J -= log(prob < 1e-20 ? 1e-20 : prob);
TSizeTy Len() const
Returns the number of elements in the vector.
void TSigmoid::EvaluateFit |
( |
const TFltIntKdV & |
data, |
|
|
const double |
A, |
|
|
const double |
B, |
|
|
double & |
J, |
|
|
double & |
JA, |
|
|
double & |
JB |
|
) |
| |
|
staticprivate |
Definition at line 1504 of file linalg.cpp.
1510 J = 0.0;
double sum_all_PyNeg = 0.0, sum_all_ziPyNeg = 0.0, sum_yNeg_zi = 0.0, sum_yNeg_1 = 0.0;
1511 for (
int i = 0; i < data.
Len(); i++)
1513 double zi = data[i].Key;
int yi = data[i].Dat;
1514 double e = exp(-
A * zi +
B);
1515 double denum = 1.0 + e;
1516 double prob = (yi > 0) ? (1.0 / denum) : (e / denum);
1517 J -= log(prob < 1e-20 ? 1e-20 : prob);
1518 sum_all_PyNeg += e / denum;
1519 sum_all_ziPyNeg += zi * e / denum;
1520 if (yi < 0) { sum_yNeg_zi += zi; sum_yNeg_1 += 1; }
1522 JA = -sum_all_ziPyNeg + sum_yNeg_zi;
1523 JB = sum_all_PyNeg - sum_yNeg_1;
TSizeTy Len() const
Returns the number of elements in the vector.
void TSigmoid::EvaluateFit |
( |
const TFltIntKdV & |
data, |
|
|
const double |
A, |
|
|
const double |
B, |
|
|
const double |
U, |
|
|
const double |
V, |
|
|
const double |
lambda, |
|
|
double & |
J, |
|
|
double & |
JJ, |
|
|
double & |
JJJ |
|
) |
| |
|
staticprivate |
Definition at line 1526 of file linalg.cpp.
1534 J = 0.0; JJ = 0.0; JJJ = 0.0;
1535 for (
int i = 0; i < data.
Len(); i++)
1537 double zi = data[i].Key;
int yi = data[i].Dat;
1538 double e = exp(-
A * zi +
B);
1539 double denum = 1.0 + e;
1540 double prob = (yi > 0) ? (1.0 / denum) : (e / denum);
1541 J -= log(prob < 1e-20 ? 1e-20 : prob);
1542 double VU = V - U * zi;
1543 JJ += VU * (e / denum);
if (yi < 0) JJ -= VU;
1544 JJJ += VU * VU * e / denum / denum;
TSizeTy Len() const
Returns the number of elements in the vector.
void TSigmoid::GetSigmoidAB |
( |
double & |
A_, |
|
|
double & |
B_ |
|
) |
| |
|
inline |
double TSigmoid::GetVal |
( |
const double & |
x | ) |
const |
|
inline |
Definition at line 484 of file linalg.h.
485 return 1.0 / (1.0 + exp(-
A * x +
B)); }
void TSigmoid::Load |
( |
TSIn & |
SIn | ) |
|
|
inline |
double TSigmoid::operator() |
( |
const double & |
x | ) |
const |
|
inline |
Definition at line 486 of file linalg.h.
double GetVal(const double &x) const
void TSigmoid::Save |
( |
TSOut & |
SOut | ) |
const |
|
inline |
Definition at line 482 of file linalg.h.
void Save(TSOut &SOut) const
The documentation for this class was generated from the following files: