1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-11-13 01:35:35 +00:00

Fit: various fixes in indexing for error-on-variable chi^2

This commit is contained in:
Antonin Portelli 2015-06-26 20:34:48 +01:00
parent 1adf182caf
commit 57d4bfb4f8
2 changed files with 23 additions and 18 deletions

View File

@ -261,7 +261,6 @@ double Chi2Function::operator()(const double *arg) const
}
// set the upper part of v: f_j(xi, p) - y_j
is = 0;
for (Index j = 0; j < yDim; ++j)
FOR_VEC(buffer_->dInd, k)
{
@ -272,6 +271,7 @@ double Chi2Function::operator()(const double *arg) const
{
LATAN_ERROR(Memory, "null model");
}
is = 0;
for (Index i = 0; i < xDim; ++i)
{
if (data_.isXExact(i))
@ -296,7 +296,7 @@ double Chi2Function::operator()(const double *arg) const
double x_ik = data_.x(buffer_->xInd(i), buffer_->dInd(k));
double xi_ik = xi(i*nPoint + k);
buffer_->v(i*nPoint + k) = xi_ik - x_ik;
buffer_->v(yDim*nPoint + i*nPoint + k) = xi_ik - x_ik;
}
// compute result
@ -314,11 +314,11 @@ DoubleFunction Chi2Function::makeFunction(const bool makeHardCopy) const
{
Chi2Function copy(*this);
res.setFunction([copy](const double *p){return copy(p);}, getNPar());
res.setFunction([copy](const double *p){return copy(p);}, getNArg());
}
else
{
res.setFunction([this](const double *p){return (*this)(p);}, getNPar());
res.setFunction([this](const double *p){return (*this)(p);}, getNArg());
}
return res;

View File

@ -236,16 +236,21 @@ FitResult XYStatData::fit(Minimizer &minimizer, const DVec &init,
fullInit.conservativeResize(chi2_.getNArg());
for (Index i = 0; i < getXDim(); ++i)
{
if (!isXExact(i))
{
kf = 0;
for (Index k = 0; k < getNData(); ++k)
{
if (isFitPoint(k))
{
fullInit(chi2_.getNPar() + nPoint*is + kf) = x(i, k);
kf++;
}
}
is++;
}
}
minimizer.setInit(fullInit);
// fit