From 3793aca27c882d29707c7473a381c6a4d6894c76 Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Wed, 16 Mar 2016 20:03:32 +0000 Subject: [PATCH] lot of fixes, XYSampleData fit now seems to work (more checks are probably needed) --- examples/Makefile.am | 80 +++++++++++++++++++--------------------- examples/exFit.cpp | 20 +++++----- examples/exFitSample.cpp | 54 +++++++++++++++++++++++++++ lib/XYSampleData.cpp | 31 +++++++++++----- utils/Makefile.am | 8 ---- 5 files changed, 123 insertions(+), 70 deletions(-) create mode 100644 examples/exFitSample.cpp diff --git a/examples/Makefile.am b/examples/Makefile.am index fce581f..0f2fa07 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,11 +1,3 @@ -if CC_GNU - COM_CFLAGS = -Wall -W -pedantic -else -if CC_INTEL - COM_CFLAGS = -Wall -endif -endif - if CXX_GNU COM_CXXFLAGS = -Wall -W -pedantic else @@ -26,55 +18,59 @@ noinst_PROGRAMS = \ exRootFinder if HAVE_MINUIT -noinst_PROGRAMS += exFit exMin +noinst_PROGRAMS += exFit exFitSample exMin endif -exCompiledDoubleFunction_SOURCES = exCompiledDoubleFunction.cpp -exCompiledDoubleFunction_CFLAGS = -g -O2 -exCompiledDoubleFunction_LDFLAGS = -L../lib/.libs -lLatAnalyze +exCompiledDoubleFunction_SOURCES = exCompiledDoubleFunction.cpp +exCompiledDoubleFunction_CXXFLAGS = $(COM_CXXFLAGS) +exCompiledDoubleFunction_LDFLAGS = -L../lib/.libs -lLatAnalyze -exDerivative_SOURCES = exDerivative.cpp -exDerivative_CFLAGS = -g -O2 -exDerivative_LDFLAGS = -L../lib/.libs -lLatAnalyze +exDerivative_SOURCES = exDerivative.cpp +exDerivative_CXXFLAGS = $(COM_CXXFLAGS) +exDerivative_LDFLAGS = -L../lib/.libs -lLatAnalyze if HAVE_MINUIT -exFit_SOURCES = exFit.cpp -exFit_CFLAGS = -g -O2 -exFit_LDFLAGS = -L../lib/.libs -lLatAnalyze +exFit_SOURCES = exFit.cpp +exFit_CXXFLAGS = $(COM_CXXFLAGS) +exFit_LDFLAGS = -L../lib/.libs -lLatAnalyze + +exFitSample_SOURCES = exFitSample.cpp +exFitSample_CXXFLAGS = $(COM_CXXFLAGS) +exFitSample_LDFLAGS = -L../lib/.libs -lLatAnalyze endif -exInterp_SOURCES = exInterp.cpp -exInterp_CFLAGS = -g -O2 -exInterp_LDFLAGS = -L../lib/.libs -lLatAnalyze +exInterp_SOURCES = exInterp.cpp +exInterp_CXXFLAGS = $(COM_CXXFLAGS) +exInterp_LDFLAGS = -L../lib/.libs -lLatAnalyze -exIntegrator_SOURCES = exIntegrator.cpp -exIntegrator_CFLAGS = -g -O2 -exIntegrator_LDFLAGS = -L../lib/.libs -lLatAnalyze +exIntegrator_SOURCES = exIntegrator.cpp +exIntegrator_CXXFLAGS = $(COM_CXXFLAGS) +exIntegrator_LDFLAGS = -L../lib/.libs -lLatAnalyze -exMat_SOURCES = exMat.cpp -exMat_CFLAGS = -g -O2 -exMat_LDFLAGS = -L../lib/.libs -lLatAnalyze +exMat_SOURCES = exMat.cpp +exMat_CXXFLAGS = $(COM_CXXFLAGS) +exMat_LDFLAGS = -L../lib/.libs -lLatAnalyze if HAVE_MINUIT -exMin_SOURCES = exMin.cpp -exMin_CFLAGS = -g -O2 -exMin_LDFLAGS = -L../lib/.libs -lLatAnalyze +exMin_SOURCES = exMin.cpp +exMin_CXXFLAGS = $(COM_CXXFLAGS) +exMin_LDFLAGS = -L../lib/.libs -lLatAnalyze endif -exMathInterpreter_SOURCES = exMathInterpreter.cpp -exMathInterpreter_CFLAGS = -g -O2 -exMathInterpreter_LDFLAGS = -L../lib/.libs -lLatAnalyze +exMathInterpreter_SOURCES = exMathInterpreter.cpp +exMathInterpreter_CXXFLAGS = $(COM_CXXFLAGS) +exMathInterpreter_LDFLAGS = -L../lib/.libs -lLatAnalyze -exPlot_SOURCES = exPlot.cpp -exPlot_CFLAGS = -g -O2 -exPlot_LDFLAGS = -L../lib/.libs -lLatAnalyze +exPlot_SOURCES = exPlot.cpp +exPlot_CXXFLAGS = $(COM_CXXFLAGS) +exPlot_LDFLAGS = -L../lib/.libs -lLatAnalyze -exRand_SOURCES = exRand.cpp -exRand_CFLAGS = -g -O2 -exRand_LDFLAGS = -L../lib/.libs -lLatAnalyze +exRand_SOURCES = exRand.cpp +exRand_CXXFLAGS = $(COM_CXXFLAGS) +exRand_LDFLAGS = -L../lib/.libs -lLatAnalyze -exRootFinder_SOURCES = exRootFinder.cpp -exRootFinder_CFLAGS = -g -O2 -exRootFinder_LDFLAGS = -L../lib/.libs -lLatAnalyze +exRootFinder_SOURCES = exRootFinder.cpp +exRootFinder_CXXFLAGS = $(COM_CXXFLAGS) +exRootFinder_LDFLAGS = -L../lib/.libs -lLatAnalyze ACLOCAL_AMFLAGS = -I .buildutils/m4 diff --git a/examples/exFit.cpp b/examples/exFit.cpp index 1da5ed7..850a142 100644 --- a/examples/exFit.cpp +++ b/examples/exFit.cpp @@ -9,7 +9,7 @@ using namespace std; using namespace Latan; const Index nPoint = 30; -const double xErr = .01, yErr = .1; +const double xErr = .2, yErr = .1; const double exactPar[2] = {0.5,5.0}, dx = 10.0/static_cast(nPoint); int main(void) @@ -17,7 +17,7 @@ int main(void) // generate fake data XYStatData data; RandGen rg; - double x_k, y_k; + double x1_k, x2_k; DoubleModel f([](const double *x, const double *p) {return p[1]*exp(-x[0]*p[0]);}, 1, 2); @@ -25,11 +25,11 @@ int main(void) data.addYDim("y"); for (Index k = 0; k < nPoint; ++k) { - x_k = k*dx + rg.gaussian(0.0, xErr); - y_k = f(&x_k, exactPar) + rg.gaussian(0.0, yErr); - printf("% 8e % 8e % 8e % 8e\n", x_k, xErr, y_k, yErr); - data.x(k) = x_k; - data.y(k) = y_k; + x1_k = rg.gaussian(k*dx, xErr); + x2_k = rg.gaussian(k*dx, xErr); + data.x(k) = x1_k; + data.y(k) = rg.gaussian(f(&x2_k, exactPar), yErr); + printf("% 8e % 8e % 8e % 8e\n", data.x(k), data.y(k), xErr, yErr); } cout << endl; data.setXError(0, DVec::Constant(nPoint, xErr)); @@ -42,9 +42,9 @@ int main(void) MinuitMinimizer minimizer; p = data.fit(minimizer, init, f); - cout << "a= " << p(0) << " b= " << p(1); - cout << " chi^2/ndof= " << p.getChi2PerDof(); - cout << " p-value= " << p.getPValue() <