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(
"Fitting x^power ");
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);
}
int Int_t
Signed integer 4 bytes (int).
double Double_t
Double 8 bytes.
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 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 SetParameter(Int_t param, Double_t value)
virtual void Add(TGraph *graph, Option_t *chopt="")
void Draw(Option_t *chopt="") override
Default Draw method for all objects.
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.
- Author
- Omar Zapata
Definition in file SimpleFitting.C.