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");
fmsg.
Form(
" \"Green\" Fitted function with power=%.4lf",power);
}
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y1
TVectorT< Double_t > TVectorD
ROOT R was implemented using the R Project library and the modules Rcpp and RInside
static TRInterface & Instance()
static method to get an TRInterface instance reference
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
virtual void SetParameter(Int_t param, Double_t value)
A TGraph is an object made of two arrays X and Y with npoints each.
A TMultiGraph is a collection of TGraph (or derived) objects.
virtual void Add(TGraph *graph, Option_t *chopt="")
Add a new graph to the list of graphs.
void Draw(Option_t *chopt="") override
Draw this multigraph with its current attributes.
A Pave (see TPave) with text, lines or/and boxes inside.
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
Add a new Text line to this pavetext at given coordinates.
void Draw(Option_t *option="") override
Draw this pavetext with its current attributes.
This is the base class for the ROOT Random number generators.
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed.
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.