Use MINUIT to minimize a linear function

Dear RootTalk,
I am trying to find parameters of complex functions. In order to familiarize myself with MINUIT, I try to begin to find the parameters a and b of a very simple function y = ax + b with my data files by using SIMPLEX method. I use MINUIT from a c++ file.
The following program is not working. Does anyone could help me find the mistake?
Many Thanks!
affine.cpp (2.82 KB)

I think you should clean up a bit your code. It does not compile. You have twice the definition of:

void getData(vector<double>* yVecPtr)

When I compile it I get:

affine.cxx:58:6: error: redefinition of 'getData'
void getData(vector<double>* yVecPtr){
     ^
affine.cxx:32:6: note: previous definition is here
void getData(vector<double>* xVecPtr){
     ^

thanks of your answer. I clean up my code. It compiles now. But the problem is that I do not know where I can put my variable “y”.
affine.cpp (2.98 KB)

Hi,

Minuit is used to minimise a function. To get the parameter a,b from your data, you need to minimise a least square function. You can do it directly using for example the TGraph class and the Graph::Fit method.
I would suggest you to read the ROOT User guide chapter on fitting

root.cern.ch/root/htmldoc/guide … ograms.pdf

Best Regards

Lorenzo

Thanks for your answer, I will try to adapt that to a c++ programm.
Great Thanks

Hi,
I tried this method on a very simple case y = ax +b with a = b = 1 but the parameters given by root are not correct. I don’t know where is my mistake.
Thanks
affine.cpp (1019 Bytes)