Create an exponential fitting The idea is to create a set of numbers x,y with the function x^3 and some noise from ROOT, fit the function to get the exponent (which must be near 3) and plot the points with noise, the known function and the fitted function
for (
Int_t i = 0; i <
n; i++) {
}
TF1 *f_known=
new TF1(
"f_known",
"pow(x,3)",0,1);
r<<"ds<-data.frame(x=x,y=y)";
r<<"m <- nls(y ~ I(x^power),data = ds, start = list(power = 1),trace = T)";
r["summary(m)$coefficients[1]"]>>power;
TF1 *f_fitted=
new TF1(
"f_fitted",
"pow(x,[0])",0,1);
pt->
AddText(
" \"Blue\" Points with gaussian noise to be fitted");
pt->
AddText(
" \"Red\" Known function x^3");
fmsg.
Form(
" \"Green\" Fitted function with power=%.4lf",power);
}
- Author
- Omar Zapata
Definition in file SimpleFitting.C.