1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-11-10 08:55:37 +00:00

normalised residuals routines

This commit is contained in:
Antonin Portelli 2021-12-20 01:30:03 +01:00
parent 24a7b9c203
commit adf2c9cc69
4 changed files with 43 additions and 0 deletions

View File

@ -346,6 +346,29 @@ XYSampleData XYSampleData::getResiduals(const SampleFitResult &fit)
return res;
}
XYSampleData XYSampleData::getNormalisedResiduals(const SampleFitResult &fit)
{
XYSampleData res(*this);
for (Index j = 0; j < getNYDim(); ++j)
{
const DoubleFunctionSample &f = fit.getModel(_, j);
for (auto &p: yData_[j])
{
res.y(p.first, j) -= f(x(p.first));
}
const DMat &var = res.getYYVar(j, j);
for (auto &p: yData_[j])
{
res.y(p.first, j) /= sqrt(var(p.first, p.first));
}
}
return res;
}
XYSampleData XYSampleData::getPartialResiduals(const SampleFitResult &fit,
const DVec &ref, const Index i)
{

View File

@ -111,6 +111,7 @@ public:
const DoubleModel &model, const Ts... models);
// residuals
XYSampleData getResiduals(const SampleFitResult &fit);
XYSampleData getNormalisedResiduals(const SampleFitResult &fit);
XYSampleData getPartialResiduals(const SampleFitResult &fit, const DVec &x,
const Index i);
private:

View File

@ -379,6 +379,24 @@ XYStatData XYStatData::getResiduals(const FitResult &fit)
return res;
}
XYStatData XYStatData::getNormalisedResiduals(const FitResult &fit)
{
XYStatData res(*this);
for (Index j = 0; j < getNYDim(); ++j)
{
const DoubleFunction &f = fit.getModel(j);
for (auto &p: yData_[j])
{
res.y(p.first, j) -= f(x(p.first));
res.y(p.first, j) /= sqrt(getYYVar(j, j)(p.first, p.first));
}
}
return res;
}
XYStatData XYStatData::getPartialResiduals(const FitResult &fit,
const DVec &ref, const Index i)
{

View File

@ -104,6 +104,7 @@ public:
const DoubleModel &model, const Ts... models);
// residuals
XYStatData getResiduals(const FitResult &fit);
XYStatData getNormalisedResiduals(const FitResult &fit);
XYStatData getPartialResiduals(const FitResult &fit, const DVec &ref,
const Index i);
protected: