ROOT logo
ROOT » HIST » HIST » TGraphSmooth

class TGraphSmooth: public TNamed

 TGraphSmooth

 A helper class to smooth TGraph
 see examples in $ROOTSYS/tutorials/graphs/motorcycle.C and approx.C


Function Members (Methods)

public:
TGraphSmooth()
TGraphSmooth(const char* name)
virtual~TGraphSmooth()
voidTObject::AbstractMethod(const char* method) const
virtual voidTObject::AppendPad(Option_t* option = "")
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")
static Double_tApprox1(Double_t v, Double_t f, Double_t* x, Double_t* y, Int_t n, Int_t iKind, Double_t Ylow, Double_t Yhigh)
voidApproxin(TGraph* grin, Int_t iKind, Double_t& Ylow, Double_t& Yhigh, Int_t rule, Int_t iTies)
static voidBDRksmooth(Double_t* x, Double_t* y, Int_t n, Double_t* xp, Double_t* yp, Int_t np, Int_t kernel, Double_t bw)
static voidBDRsmooth(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)
static voidBDRsupsmu(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)
virtual voidTObject::Browse(TBrowser* b)
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidTNamed::Clear(Option_t* option = "")
virtual TObject*TNamed::Clone(const char* newname = "") const
virtual Int_tTNamed::Compare(const TObject* obj) const
virtual voidTNamed::Copy(TObject& named) const
virtual voidTObject::Delete(Option_t* option = "")MENU
virtual Int_tTObject::DistancetoPrimitive(Int_t px, Int_t py)
virtual voidTObject::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTObject::Dump() constMENU
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual voidTNamed::FillBuffer(char*& buffer)
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
virtual const char*TObject::GetIconName() const
virtual const char*TNamed::GetName() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
virtual const char*TNamed::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTNamed::Hash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTObject::IsFolder() const
Bool_tTObject::IsOnHeap() const
virtual Bool_tTNamed::IsSortable() const
Bool_tTObject::IsZombie() const
voidLowess(Double_t* x, Double_t* y, Int_t n, Double_t* ys, Double_t span, Int_t iter, Double_t delta)
static voidLowest(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)
virtual voidTNamed::ls(Option_t* option = "") const
voidTObject::MayNotUse(const char* method) const
virtual Bool_tTObject::Notify()
voidTObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const
static voidTObject::operator delete(void* ptr)
static voidTObject::operator delete(void* ptr, void* vp)
static voidTObject::operator delete[](void* ptr)
static voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
virtual voidTObject::Paint(Option_t* option = "")
virtual voidTObject::Pop()
virtual voidTNamed::Print(Option_t* option = "") const
static voidPsort(Double_t* x, Int_t n, Int_t k)
static voidRank(Int_t n, Double_t* a, Int_t* index, Int_t* rank, Bool_t down = kTRUE)
static Int_tRcmp(Double_t x, Double_t y)
virtual Int_tTObject::Read(const char* name)
virtual voidTObject::RecursiveRemove(TObject* obj)
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTObject::SavePrimitive(ostream& out, Option_t* option = "")
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
virtual voidTNamed::SetName(const char* name)MENU
virtual voidTNamed::SetNameTitle(const char* name, const char* title)
static voidTObject::SetObjectStat(Bool_t stat)
virtual voidTNamed::SetTitle(const char* title = "")MENU
virtual voidTObject::SetUniqueID(UInt_t uid)
virtual voidShowMembers(TMemberInspector&)
virtual Int_tTNamed::Sizeof() const
voidSmoothin(TGraph* grin)
TGraph*SmoothKern(TGraph* grin, Option_t* option = "normal", Double_t bandwidth = 0.5, Int_t nout = 100, Double_t* xout = 0)
TGraph*SmoothLowess(TGraph* grin, Option_t* option = "", Double_t span = 0.67, Int_t iter = 3, Double_t delta = 0)
TGraph*SmoothSuper(TGraph* grin, Option_t* option = "", Double_t bass = 0, Double_t span = 0, Bool_t isPeriodic = kFALSE, Double_t* w = 0)
virtual voidStreamer(TBuffer&)
voidStreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
protected:
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
voidTObject::MakeZombie()

Data Members

protected:
TGraph*fGinInput graph
TGraph*fGoutOutput graph
Double_tfMaxXMaximum value of array X
Double_tfMinXMinimum value of array X
TStringTNamed::fNameobject identifier
Int_tfNinNumber of input points
Int_tfNoutNumber of output points
TStringTNamed::fTitleobject title

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

TGraphSmooth()
Default GraphSmooth constructor *-*-

TGraphSmooth(const char* name)
GraphSmooth constructor *-*-*-*-*-*-

~TGraphSmooth()
GraphSmooth destructor*-*-*-*-*-*-*-

void Smoothin(TGraph* grin)
Sort input data points*-*-*-*-*-*-*-

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*-*-


 Smooth grin with the Nadaraya-Watson kernel regression estimate.

 Arguments:
 grin:      input graph

 option:    the kernel to be used: "box", "normal"
 bandwidth: the bandwidth. The kernels are scaled so that their quartiles
            (viewed as probability densities) are at +/- 0.25*bandwidth.
 nout:      If xout is not specified, interpolation takes place at equally
            spaced points spanning the interval [min(x), max(x)], where
            nout = max(nout, number of input data).
 xout:      an optional set of values at which to evaluate the fit

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*-*-
*-*              =================================

   Based on R function ksmooth: Translated to C++ by C. Stratowa
   (R source file: ksmooth.c by B.D.Ripley Copyright (C) 1998)

-
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*-*-


 This function performs the computations for the LOWESS smoother
 (see the reference below). Lowess returns the output points
 x and y which give the coordinates of the smooth.

 Arguments:
 grin:  Input graph

 span:  the smoother span. This gives the proportion of points in the plot
        which influence the smooth at each value.
        Larger values give more smoothness.
 iter:  the number of robustifying iterations which should be performed.
        Using smaller values of iter will make lowess run faster.
 delta: values of x which lie within delta of each other replaced by a
        single value in the output from lowess.
        For delta = 0, delta will be calculated.

 References:
 Cleveland, W. S. (1979) Robust locally weighted regression and smoothing
        scatterplots. J. Amer. Statist. Assoc. 74, 829-836.
 Cleveland, W. S. (1981) LOWESS: A program for smoothing scatterplots
        by robust locally weighted regression.
        The American Statistician, 35, 54.

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*-*-*-*-*-

   Based on R function clowess: Translated to C++ by C. Stratowa
   (R source file: lowess.c by R Development Core Team (C) 1999-2001)

-
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. Stratowa
  (R source file: lowess.c by R Development Core Team (C) 1999-2001)

-
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*-*-*-


 Smooth the (x, y) values by Friedman's ``super smoother''.

 Arguments:
 grin: graph for smoothing

 span: the fraction of the observations in the span of the running lines
        smoother, or 0 to choose this by leave-one-out cross-validation.
 bass: controls the smoothness of the fitted curve.
        Values of up to 10 indicate increasing smoothness.
 isPeriodic: if TRUE, the x values are assumed to be in [0, 1]
        and of period 1.
 w:     case weights

 Details:
 supsmu is a running lines smoother which chooses between three spans for
 the lines. The running lines smoothers are symmetric, with k/2 data points
 each side of the predicted point, and values of k as 0.5 * n, 0.2 * n and
 0.05 * n, where n is the number of data points. If span is specified,
 a single smoother with span span * n is used.

 The best of the three smoothers is chosen by cross-validation for each
 prediction. The best spans are then smoothed by a running lines smoother
 and the final prediction chosen by linear interpolation.

 The FORTRAN code says: ``For small samples (n < 40) or if there are
 substantial serial correlations between observations close in x - value,
 then a prespecified fixed span smoother (span > 0) should be used.
 Reasonable span values are 0.2 to 0.4.''

 References:
 Friedman, J. H. (1984) SMART User's Guide.
           Laboratory for Computational Statistics,
           Stanford University Technical Report No. 1.

 Friedman, J. H. (1984) A variable span scatterplot smoother.
           Laboratory for Computational Statistics,
           Stanford University Technical Report No. 5.

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)
Friedmannīs super smoother *-*-*-*-*-


  super smoother (Friedman, 1984).

  version 10/10/84

  coded  and copywrite (c) 1984 by:

                         Jerome H. Friedman
                      department of statistics
                                and
                 stanford linear accelerator center
                         stanford university

  all rights reserved.


  input:
     n : number of observations (x,y - pairs).
     x(n) : ordered abscissa values.
     y(n) : corresponding ordinate (response) values.
     w(n) : weight for each (x,y) observation.
     iper : periodic variable flag.
        iper=1 => x is ordered interval variable.
        iper=2 => x is a periodic variable with values
                  in the range (0.0,1.0) and period 1.0.
     span : smoother span (fraction of observations in window).
            span=0.0 => automatic (variable) span selection.
     alpha : controls high frequency (small span) penality
             used with automatic span selection (bass tone control).
             (alpha.le.0.0 or alpha.gt.10.0 => no effect.)
  output:
    smo(n) : smoothed ordinate (response) values.
  scratch:
    sc(n,7) : internal working storage.

  note:
     for small samples (n < 40) or if there are substantial serial
     correlations between observations close in x - value, then
     a prespecified fixed span smoother (span > 0) should be
     used. reasonable span values are 0.2 to 0.4.

 current implementation:
   Based on R function supsmu: Translated to C++ by C. Stratowa
   (R source file: ppr.f by B.D.Ripley Copyright (C) 1994-97)

-
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. Stratowa
   (R source file: ppr.f by B.D.Ripley Copyright (C) 1994-97)

-
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

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*-*-*-*-*-*-*-


 Arguments:
 grin:  graph giving the coordinates of the points to be interpolated.
        Alternatively a single plotting structure can be specified:

 option: specifies the interpolation method to be used.
        Choices are "linear" (iKind = 1) or "constant" (iKind = 2).
 nout:  If xout is not specified, interpolation takes place at n equally
        spaced points spanning the interval [min(x), max(x)], where
        nout = max(nout, number of input data).
 xout:  an optional set of values specifying where interpolation is to
        take place.
 yleft: the value to be returned when input x values less than min(x).
        The default is defined by the value of rule given below.
 yright: the value to be returned when input x values greater than max(x).
        The default is defined by the value of rule given below.
 rule:  an integer describing how interpolation is to take place outside
        the interval [min(x), max(x)]. If rule is 0 then the given yleft
        and yright values are returned, if it is 1 then 0 is returned
        for such points and if it is 2, the value at the closest data
        extreme is used.
 f:     For method="constant" a number between 0 and 1 inclusive,
        indicating a compromise between left- and right-continuous step
        functions. If y0 and y1 are the values to the left and right of
        the point then the value is y0*f+y1*(1-f) so that f=0 is
        right-continuous and f=1 is left-continuous
 ties:  Handling of tied x values. An integer describing a function with
        a single vector argument returning a single number result:
        ties = "ordered" (iTies = 0): input x are "ordered"
        ties = "mean"    (iTies = 1): function "mean"
        ties = "min"     (iTies = 2): function "min"
        ties = "max"     (iTies = 3): function "max"

 Details:
 At least two complete (x, y) pairs are required.
 If there are duplicated (tied) x values and ties is a function it is
 applied to the y values for each distinct x value. Useful functions in
 this context include mean, min, and max.
 If ties="ordered" the x values are assumed to be already ordered. The
 first y value will be used for interpolation to the left and the last
 one for interpolation to the right.

 Value:
 approx returns a graph with components x and y, containing n coordinates
 which interpolate the given data points according to the method (and rule)
 desired.
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*-*-*-*-*-
*-*              ==========================

   Approximate  y(v),  given (x,y)[i], i = 0,..,n-1
   Based on R function approx1: Translated to C++ by Christian Stratowa
   (R source file: approx.c by R Development Core Team (C) 1999-2001)

Int_t Rcmp(Double_t x, Double_t y)
   static function
   if (ISNAN(x))   return 1;
   if (ISNAN(y))   return -1;
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_sort.c by R Development Core Team (C) 1999-2001)

void Rank(Int_t n, Double_t* a, Int_t* index, Int_t* rank, Bool_t down = kTRUE)
   static function
TGraphSmooth(const TGraphSmooth& )
TGraphSmooth& operator=(const TGraphSmooth& )