Skip to content

Fitting

gavalian edited this page Aug 1, 2018 · 4 revisions

Fitting

Take the first histogram demo. Now you can take that histogram and fit it with a function.

Create your function using the built in function builder

F1D f1 = new F1D("f1","[amp]*gaus(x,[mean],[sigma])", -5.0, 5.0);
f1.setParameter(0, 100.0);
f1.setParameter(1, 0.0);
f1.setParameter(2, 1.0);

Fit with the DataFitter

DataFitter.fit(f1, histogram, "Q"); //No options uses error for sigma
canvas.draw(f1,"same");
System.out.println(" par = " + f1.parameter(0).value() 
         + " error = " + f1.parameter(0).error());
Clone this wiki locally