1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-11-14 09:45:36 +00:00

minor fixes

This commit is contained in:
Antonin Portelli 2014-10-14 16:36:20 +01:00
parent 9e6bbd95c3
commit 89cf008fb8
5 changed files with 13 additions and 8 deletions

View File

@ -17,14 +17,16 @@ int main(void)
// generate fake data // generate fake data
XYStatData data(nPoint, 1, 1); XYStatData data(nPoint, 1, 1);
RandGen rg; RandGen rg;
double x_k; double x_k, y_k;
CompiledDoubleModel f(1, 2, "return p_1*exp(-x_0*p_0);"); CompiledDoubleModel f(1, 2, "return p_1*exp(-x_0*p_0);");
for (Index k = 0; k < nPoint; ++k) for (Index k = 0; k < nPoint; ++k)
{ {
x_k = k*dx; x_k = k*dx;
y_k = f(&x_k, exactPar) + rg.gaussian(0.0, 0.1);
cout << x_k << " " << y_k << " " << 0.1 << endl;
data.x(0, k) = x_k; data.x(0, k) = x_k;
data.y(0, k) = f(&x_k, exactPar) + rg.gaussian(0.0, 0.1); data.y(0, k) = y_k;
} }
data.yyVar(0, 0).diagonal() = DMat::Constant(nPoint, 1, 0.1*0.1); data.yyVar(0, 0).diagonal() = DMat::Constant(nPoint, 1, 0.1*0.1);
data.assumeXExact(0); data.assumeXExact(0);
@ -32,7 +34,7 @@ int main(void)
// fit // fit
DVec init = DVec::Constant(2, 0.5); DVec init = DVec::Constant(2, 0.5);
FitResult p; FitResult p;
MinuitMinimizer minimizer; MinuitMinimizer minimizer(2);
data.fitAllPoints(); data.fitAllPoints();
p = data.fit(minimizer, init, f); p = data.fit(minimizer, init, f);

View File

@ -18,7 +18,7 @@ int main(int argc, char* argv[])
source = argv[1]; source = argv[1];
CompiledDoubleFunction f(1, source); CompiledDoubleFunction f(1, source);
MinuitMinimizer minimizer; MinuitMinimizer minimizer(1);
double min; double min;
minimizer.setVerbosity(Minimizer::Verbosity::Debug); minimizer.setVerbosity(Minimizer::Verbosity::Debug);

View File

@ -11,7 +11,7 @@ int main(void)
DoubleFunction f1(2, [a](const double *x){return a*(1.-x[0]);}); DoubleFunction f1(2, [a](const double *x){return a*(1.-x[0]);});
DoubleFunction f2(2, [b](const double *x){return b*(x[1]-x[0]*x[0]);}); DoubleFunction f2(2, [b](const double *x){return b*(x[1]-x[0]*x[0]);});
vector<DoubleFunction *> system = {&f1, &f2}; vector<DoubleFunction *> system = {&f1, &f2};
GslHybridRootFinder solve; GslHybridRootFinder solve(2);
DVec init(2), x; DVec init(2), x;
solve.setVerbosity(Solver::Verbosity::Debug); solve.setVerbosity(Solver::Verbosity::Debug);

View File

@ -68,7 +68,10 @@ double TabFunction::operator()(const double *arg) const
if ((x < value_.begin()->first)||(x >= value_.rbegin()->first)) if ((x < value_.begin()->first)||(x >= value_.rbegin()->first))
{ {
LATAN_ERROR(Range, "tabulated function variable out of range"); LATAN_ERROR(Range, "tabulated function variable out of range (x= "
+ strFrom(x) + " not in ["
+ strFrom(value_.begin()->first) + ", "
+ strFrom(value_.rbegin()->first) + "])");
} }
auto i = value_.equal_range(x); auto i = value_.equal_range(x);

View File

@ -53,7 +53,7 @@ public:
const Index j = 0) const; const Index j = 0) const;
private: private:
DSample chi2_; DSample chi2_;
Index nDof_{0}; double nDof_{0.};
std::vector<DoubleFunctionSample> model_; std::vector<DoubleFunctionSample> model_;
}; };