22void makePoints(
int n, 
double *
x, 
double *
y, 
double *
e, 
int p);
 
   27   double *
x = 
new double[
n];
 
   28   double *
y = 
new double[
n];
 
   29   double *
e = 
new double[
n];
 
   31      "Fitting 3 TGraphErrors with linear functions");
 
   35   makePoints(
n, 
x, 
y, 
e, 3);
 
   45   makePoints(
n, 
x, 
y, 
e, 2);
 
   57   TF1 *f2 = 
new TF1(
"f2", 
"sin(x) ++ sin(2*x)", -2, 2);
 
   64   makePoints(
n, 
x, 
y, 
e, 4);
 
   71   gre4->
Fit(
"1 ++ exp(-x)");
 
   79   leg->AddEntry(gre3, 
" -7 + 2*x*x + x*x*x", 
"p");
 
   80   leg->AddEntry(gre2, 
"sin(x) + sin(2*x)", 
"p");
 
   81   leg->AddEntry(gre4, 
"-2 + exp(-x)", 
"p");
 
   86void makePoints(
int n, 
double *
x, 
double *
y, 
double *
e, 
int p)
 
   93      x[i] = 
r.Uniform(-2, 2);
 
  100      x[i] = 
r.Uniform(-2, 2);
 
  101      y[i] = -7 + 2*
x[i]*
x[i] + 
x[i]*
x[i]*
x[i]+ 
r.Gaus()*0.1;
 
  106    for (i=0; i<
n; i++) {
 
  107      x[i] = 
r.Uniform(-2, 2);
 
winID h TVirtualViewer3D TVirtualGLPainter p
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
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
A TGraphErrors is a TGraph with error bars.
TF1 * GetFunction(const char *name) const
Return pointer to function with name.
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Axis_t xmin=0, Axis_t xmax=0)
Fit this graph with function with name fname.
void Draw(Option_t *chopt="") override
Draw this graph with its current attributes.
This class displays a legend box (TPaveText) containing several legend entries.
virtual void SetName(const char *name)
Set the name of the TNamed.
void SetGrid(Int_t valuex=1, Int_t valuey=1) override
This is the base class for the ROOT Random number generators.
Double_t Exp(Double_t x)
Returns the base-e exponential function of x, which is e raised to the power x.
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.