35 for (i=0; i<fraction; i++){
37 x[i]=
r.Uniform(-2, 2);
39 y[i]=1 + 2*
x[i] + 3*
x[i]*
x[i] + 4*
x[i]*
x[i]*
x[i] +
e[i]*
r.Gaus();
41 for (i=fraction; i<npoints; i++){
43 x[i]=
r.Uniform(-1, 1);
45 y[i] = 1 + 2*
x[i] + 3*
x[i]*
x[i] + 4*
x[i]*
x[i]*
x[i] +
r.Landau(10, 5);
51 TF1 *ffit1 =
new TF1(
"ffit1",
"pol3", -5, 5);
52 TF1 *ffit2 =
new TF1(
"ffit2",
"pol3", -5, 5);
55 TCanvas *myc =
new TCanvas(
"myc",
"Linear and robust linear fitting");
59 printf(
"Ordinary least squares:\n");
64 printf(
"Resistant Least trimmed squares fit:\n");
71 grr->
Fit(ffit2,
"+rob=0.75");
74 leg->AddEntry(ffit1,
"Ordinary least squares",
"l");
75 leg->AddEntry(ffit2,
"LTS regression",
"l");
virtual void SetLineColor(Color_t lcolor)
Set the line color.
A TGraphErrors is a TGraph with error bars.
virtual void SetMaximum(Double_t maximum=-1111)
Set the maximum of the graph.
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.
virtual void Draw(Option_t *chopt="")
Draw this graph with its current attributes.
virtual void SetMinimum(Double_t minimum=-1111)
Set the minimum of the graph.
This class displays a legend box (TPaveText) containing several legend entries.
virtual void SetGrid(Int_t valuex=1, Int_t valuey=1)
This is the base class for the ROOT Random number generators.