1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2025-05-01 17:35:55 +01: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 // set the upper part of v: f_j(xi, p) - y_j
is = 0;
for (Index j = 0; j < yDim; ++j) for (Index j = 0; j < yDim; ++j)
FOR_VEC(buffer_->dInd, k) FOR_VEC(buffer_->dInd, k)
{ {
@ -272,6 +271,7 @@ double Chi2Function::operator()(const double *arg) const
{ {
LATAN_ERROR(Memory, "null model"); LATAN_ERROR(Memory, "null model");
} }
is = 0;
for (Index i = 0; i < xDim; ++i) for (Index i = 0; i < xDim; ++i)
{ {
if (data_.isXExact(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 x_ik = data_.x(buffer_->xInd(i), buffer_->dInd(k));
double xi_ik = xi(i*nPoint + 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 // compute result
@ -314,11 +314,11 @@ DoubleFunction Chi2Function::makeFunction(const bool makeHardCopy) const
{ {
Chi2Function copy(*this); Chi2Function copy(*this);
res.setFunction([copy](const double *p){return copy(p);}, getNPar()); res.setFunction([copy](const double *p){return copy(p);}, getNArg());
} }
else else
{ {
res.setFunction([this](const double *p){return (*this)(p);}, getNPar()); res.setFunction([this](const double *p){return (*this)(p);}, getNArg());
} }
return res; return res;

View File

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