Logo ROOT   6.08/07
Reference Guide
TGraphSmooth.h
Go to the documentation of this file.
1 // @(#)root/hist:$Id$
2 // Author: Christian Stratowa 30/09/2001
3 
4 /******************************************************************************
5 * Copyright(c) 2001- , Dr. Christian Stratowa, Vienna, Austria. *
6 * Author: Christian Stratowa with help from Rene Brun. *
7 * *
8 * Algorithms for smooth regression adapted from: *
9 * R: A Computer Language for Statistical Data Analysis *
10 * Copyright (C) 1996 Robert Gentleman and Ross Ihaka *
11 * Copyright (C) 1999-2001 Robert Gentleman, Ross Ihaka and the *
12 * R Development Core Team *
13 * R is free software, for licensing see the GNU General Public License *
14 * http://www.ci.tuwien.ac.at/R-project/welcome.html *
15 * *
16 * Based on: "The ROOT System", All rights reserved. *
17 * Authors: Rene Brun and Fons Rademakers. *
18 * For the licensing terms of "The ROOT System" see $ROOTSYS/AA_LICENSE. *
19 * For the list of contributors to "The ROOT System" see $ROOTSYS/AA_CREDITS. *
20 ******************************************************************************/
21 
22 #ifndef ROOT_TGraphSmooth
23 #define ROOT_TGraphSmooth
24 
25 //////////////////////////////////////////////////////////////////////////
26 // //
27 // TGraphSmooth //
28 // //
29 // Class for different regression smoothers //
30 // //
31 //////////////////////////////////////////////////////////////////////////
32 
33 #ifndef ROOT_TGraph
34 #include "TGraph.h"
35 #endif
36 
37 
38 class TGraphSmooth: public TNamed {
39 
40 private:
41  TGraphSmooth(const TGraphSmooth&); // Not implented
42  TGraphSmooth& operator=(const TGraphSmooth&); // Not implented
43 
44 protected:
45  Int_t fNin; //Number of input points
46  Int_t fNout; //Number of output points
47  TGraph *fGin; //Input graph
48  TGraph *fGout; //Output graph
49  Double_t fMinX; //Minimum value of array X
50  Double_t fMaxX; //Maximum value of array X
51 
52 public :
53  TGraphSmooth();
54  TGraphSmooth(const char *name);
55 // TGraphSmooth(const TGraphSmooth &smoothReg); //??
56  virtual ~TGraphSmooth();
57 
58  TGraph *Approx(TGraph *grin, Option_t *option="linear", Int_t nout=50, Double_t *xout=0,
59  Double_t yleft=0, Double_t yright=0, Int_t rule=0, Double_t f=0, Option_t *ties="mean");
60  TGraph *SmoothKern(TGraph *grin, Option_t *option="normal", Double_t bandwidth=0.5, Int_t nout=100, Double_t *xout=0);
61  TGraph *SmoothLowess(TGraph *grin, Option_t *option="",Double_t span=0.67, Int_t iter = 3, Double_t delta = 0);
62  TGraph *SmoothSuper(TGraph *grin, Option_t *option="", Double_t bass = 0, Double_t span=0, Bool_t isPeriodic = kFALSE, Double_t *w=0);
63 
64  void Approxin(TGraph *grin, Int_t iKind, Double_t &Ylow, Double_t &Yhigh, Int_t rule, Int_t iTies);
65  void Smoothin(TGraph *grin);
66  static Double_t Approx1(Double_t v, Double_t f, Double_t *x, Double_t *y, Int_t n, Int_t iKind, Double_t Ylow, Double_t Yhigh);
67  void Lowess(Double_t *x, Double_t *y, Int_t n, Double_t *ys, Double_t span, Int_t iter, Double_t delta);
68  static void Lowest(Double_t *x, Double_t *y, Int_t n, Double_t &xs,
69  Double_t &ys, Int_t nleft, Int_t nright, Double_t *w, Bool_t userw, Double_t *rw, Bool_t &ok);
70  static Int_t Rcmp(Double_t x, Double_t y);
71  static void Psort(Double_t *x, Int_t n, Int_t k);
72  static void Rank(Int_t n, Double_t *a, Int_t *index, Int_t *rank, Bool_t down=kTRUE);
73  static void BDRksmooth(Double_t *x, Double_t *y, Int_t n,
74  Double_t *xp, Double_t *yp, Int_t np, Int_t kernel, Double_t bw);
75  static void BDRsupsmu(Int_t n, Double_t *x, Double_t *y, Double_t *w, Int_t iper,
76  Double_t span, Double_t alpha, Double_t *smo, Double_t *sc);
77  static void BDRsmooth(Int_t n, Double_t *x, Double_t *y, Double_t *w,
78  Double_t span, Int_t iper, Double_t vsmlsq, Double_t *smo, Double_t *acvr);
79 
80  ClassDef(TGraphSmooth,1) //Graph Smoother
81 };
82 
83 #endif
static void BDRsupsmu(Int_t n, Double_t *x, Double_t *y, Double_t *w, Int_t iper, Double_t span, Double_t alpha, Double_t *smo, Double_t *sc)
Friedmanns super smoother (Friedman, 1984).
TGraph * SmoothKern(TGraph *grin, Option_t *option="normal", Double_t bandwidth=0.5, Int_t nout=100, Double_t *xout=0)
Smooth data with Kernel smoother.
virtual ~TGraphSmooth()
GraphSmooth destructor.
const char Option_t
Definition: RtypesCore.h:62
void Approxin(TGraph *grin, Int_t iKind, Double_t &Ylow, Double_t &Yhigh, Int_t rule, Int_t iTies)
Sort data points and eliminate double x values.
Double_t fMaxX
Definition: TGraphSmooth.h:50
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TArc * a
Definition: textangle.C:12
const Bool_t kFALSE
Definition: Rtypes.h:92
A helper class to smooth TGraph.
Definition: TGraphSmooth.h:38
TGraph * SmoothSuper(TGraph *grin, Option_t *option="", Double_t bass=0, Double_t span=0, Bool_t isPeriodic=kFALSE, Double_t *w=0)
Smooth data with Super smoother.
static void Lowest(Double_t *x, Double_t *y, Int_t n, Double_t &xs, Double_t &ys, Int_t nleft, Int_t nright, Double_t *w, Bool_t userw, Double_t *rw, Bool_t &ok)
Fit value at x[i] Based on R function lowest: Translated to C++ by C.
TGraph * fGin
Definition: TGraphSmooth.h:47
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
TGraph * SmoothLowess(TGraph *grin, Option_t *option="", Double_t span=0.67, Int_t iter=3, Double_t delta=0)
Smooth data with Lowess smoother.
TGraph * fGout
Definition: TGraphSmooth.h:48
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
void Lowess(Double_t *x, Double_t *y, Int_t n, Double_t *ys, Double_t span, Int_t iter, Double_t delta)
Lowess regression smoother.
static Int_t Rcmp(Double_t x, Double_t y)
Static function if (ISNAN(x)) return 1; if (ISNAN(y)) return -1;.
SVector< double, 2 > v
Definition: Dict.h:5
static void BDRsmooth(Int_t n, Double_t *x, Double_t *y, Double_t *w, Double_t span, Int_t iper, Double_t vsmlsq, Double_t *smo, Double_t *acvr)
Function for super smoother Based on R function supsmu: Translated to C++ by C.
double f(double x)
double Double_t
Definition: RtypesCore.h:55
Double_t y[n]
Definition: legend1.C:17
static void Rank(Int_t n, Double_t *a, Int_t *index, Int_t *rank, Bool_t down=kTRUE)
static function
TGraph * Approx(TGraph *grin, Option_t *option="linear", Int_t nout=50, Double_t *xout=0, Double_t yleft=0, Double_t yright=0, Int_t rule=0, Double_t f=0, Option_t *ties="mean")
Approximate data points.
Double_t fMinX
Definition: TGraphSmooth.h:49
void Smoothin(TGraph *grin)
Sort input data points.
static void Psort(Double_t *x, Int_t n, Int_t k)
Static function based on R function rPsort: adapted to C++ by Christian Stratowa (R source file: R_so...
A Graph is a graphics object made of two arrays X and Y with npoints each.
Definition: TGraph.h:53
TGraphSmooth & operator=(const TGraphSmooth &)
const Bool_t kTRUE
Definition: Rtypes.h:91
static Double_t Approx1(Double_t v, Double_t f, Double_t *x, Double_t *y, Int_t n, Int_t iKind, Double_t Ylow, Double_t Yhigh)
Approximate one data point.
const Int_t n
Definition: legend1.C:16
char name[80]
Definition: TGX11.cxx:109
static void BDRksmooth(Double_t *x, Double_t *y, Int_t n, Double_t *xp, Double_t *yp, Int_t np, Int_t kernel, Double_t bw)
Smooth data with specified kernel.