BRAT 2.4.5
Class index
Full class index
brahmlib
BRAHMS
ROOT page

BrStatistics


class description - source file - inheritance tree

class BrStatistics : public TObject


    public:
BrStatistics BrStatistics() BrStatistics BrStatistics(Int_t dimension, Bool_t storeData = kFALSE, Int_t size = 100) BrStatistics BrStatistics(BrStatistics&) virtual void ~BrStatistics() static void AddPoint(Double_t data, UInt_t n, Double_t& average, Double_t& sqvar) virtual void AddRow(Double_t* row) virtual void Browse(TBrowser* b) static TClass* Class() static void CombineSamples(UInt_t n1, Double_t m1, Double_t s1, UInt_t n2, Double_t m2, Double_t s2, Double_t& m, Double_t& s) virtual void Draw(Option_t* option) virtual Double_t GetAverage(Int_t i) const virtual const TArrayD& GetAverageArray() const virtual Double_t GetCorrelation(Int_t i, Int_t j) const virtual Double_t GetCovariance(Int_t i, Int_t j) const virtual const TArrayD& GetCovarianceArray() const virtual Double_t GetFluctuation(Int_t i, Int_t j) const virtual Double_t GetMax(Int_t i) const virtual const TArrayD& GetMaxArray() const virtual Double_t GetMin(Int_t i) const virtual const TArrayD& GetMinArray() const virtual Double_t* GetRow(Int_t i) const virtual Int_t GetSampleSize() virtual Double_t GetVariance(Int_t i) const virtual TClass* IsA() const virtual Bool_t IsDataStored() const virtual void Print(Option_t* option = "balus") const virtual TH1* Project(Int_t i) virtual TH1* Project(Int_t i, Int_t j) virtual TH1* Project(Int_t i, Int_t j, Int_t k) virtual void Set(Int_t n, Bool_t store = kFALSE, Int_t m = 100) virtual void ShowMembers(TMemberInspector& insp, char* parent) virtual void Streamer(TBuffer& b) void StreamerNVirtual(TBuffer& b)

Data Members

    private:
Int_t fN Dimension of sample Int_t fM Size of sample TArrayD fAverage Average of the sample variables TArrayD fMax Max of the sample variables TArrayD fMin Min of the sample variables TArrayD fCovariance Covariance matrix Bool_t fDataStored Store data tuples? Int_t fMmem Allocated memory TArrayD fData The sample

Class Description

 Class for low-level statistics



/*

Given M input tuples of the form

(x1, ..., xN)    ,

this class will calculate the sample covariance

Cij = 1 / M ∑kM (xi,k - <xi>) (xj,k - <xj>)     ,

and the average (or sample mean) values

<xi> = 1 / M ∑kM xi,k    ,

As well as determind the minimum ximin and maximum ximax of each of N variables

Forall xi,k in {xi,1,..., i,M} : ximax ≥ xi,k

Forall xi,k in {xi,1,..., i,M} : ximin ≤ xi,k

The algorithms used are the same as in TPrincipal (see the TPrincipal::AddRow method), as to minimise rounding errors.

N can be as large as the underlying OS allows (the class contains a N×N matrix plus 3 N vectors). The class uses double precision variables for optimal precision.

This class is usefull to obtains various statistical moments of a data sample. Furhter, the class is persistent. As far as possible, the class methods are inline to improve speed.

*/ $Id: BrStatistics.cxx,v 1.7 2002/08/30 20:35:04 videbaek Exp $

BrStatistics()
 Default CTOR, do not use

BrStatistics(Int_t n, Bool_t storeData, Int_t m)
 Create a low-level statistics object for n variables, with
 initial room for m rows.  n must be bigger than 1.  For one
 variable statistics, use the static AddPoint method for
 high-precision statistics.

~BrStatistics()
 Destructor

void CombineSamples(UInt_t n1, Double_t m1, Double_t s1, UInt_t n2, Double_t m2, Double_t s2, Double_t& m, Double_t& s)
 Static method.
 Given the two partial sample of the same stocastic variable, of
 size n1 and n2, with averages m1 and m2, and square variances,
 s1 and s2, calculate the full sample average and square variance,
 and return them in m and s.  The formulas used are:

       n1 * m1 + n2 * m2
   m = -----------------
           n1 + n2

       n1 * s1 + n2 * s2   n1 * n2 * (m1 - m2)^2
   s = ----------------- + ---------------------
           n1 + n2              (n1 + n2)^2


void AddPoint(Double_t data, UInt_t n, Double_t& average, Double_t& sqvar)
 Static method to add a point to a 1D statistics. The arguments
 are:

    data       the n'th data point
    n          number of data point (must be in [1,M])
    average    on input this must be the average after n-1 data
               points. On output this contains the new average
    sqvar      on input this must be the sqyare variance after n-1
               data points. On output this contains the new square
               variance

 The algorithm is the one used in TPrincipal::AddRow.


void AddRow(Double_t* row)
 Add one row (observation) to the statisical sample. Values are
 stored internally. Average, Max, Min, and the covariance matrix
 is calculated on the fly (It actually improves accuary).  See
 also TPrincipal::AddRow.

void Draw(Option_t* option)
 Draw variables as given by option. The form of the option is
   <option> ::= <var list><option list>
 where
   <var list>    ::= <quantity>
                  |  <var number>
                  |  <var number>:<var number>
                  |  <var number>:<var number>:<var number>

   <option list> ::=
                  |  ::<histogram draw option>

   <quantity>    ::= one of A, S, C, L, U

 where <histogram draw option> is any valid histogram option for
 the type of histogram drawn (1D, 2D, or 3D). See TH1::Draw.

 The <quantity>'s corresponds to

    A           Average in each variable (1D)
    S           Spread in each varaible (1D)
    C           Covariance matrix (2D)
    L           Mimimum in each varaible (1D)
    U           Maximum in each variable (1D)
    F           Spread^2 / average in each variable  (1D)
    G           Spread^2 / average^2 in each variable (1D)
    W           Covariance / sqrt(average * average) in each cell (2D)
    X           Covariance / (average * average) in each cell (2D)
    K           Correlation matrix (2D)
    V           Alias for S
    M           Alias for A

Double_t* GetRow(Int_t i) const
 Get a pointer into internal data, starting at row i

TH1* Project(Int_t i)
 Project variable i into a 1D histogram (TH1D).  User
 need to store the histogram immediately

TH1* Project(Int_t i, Int_t j)
 Project variables i and j into a 2D histogram (TH2D).  User need
 to cast the returned histogram to a TH2D pointer. User need to
 store the histogram immediately

TH1* Project(Int_t i, Int_t j, Int_t k)
 Project variables i, j and k into a 3D histogram (TH3D). User
 need to store the histogram immediately

void Print(Option_t* option) const
 Print the statistics
 Options:
    B            Basic information
    A            Average (a.k.a. sample mean)
    L            Minimum
    U            Maximum
    S            Spread
    C            Covariance matrix
    F            Fluctuation matrix
    K            Kovariance matrix
    D            Data
 Default is BALUS

void Set(Int_t n, Bool_t store, Int_t m)
   Set the dimension and initial size of the sample storage, if
   store is true. All arrays are reset



Inline Functions


                  void Browse(TBrowser* b)
                 Int_t GetSampleSize()
              Double_t GetMax(Int_t i) const
        const TArrayD& GetMaxArray() const
              Double_t GetCovariance(Int_t i, Int_t j) const
        const TArrayD& GetCovarianceArray() const
              Double_t GetAverage(Int_t i) const
        const TArrayD& GetAverageArray() const
              Double_t GetMin(Int_t i) const
        const TArrayD& GetMinArray() const
              Double_t GetVariance(Int_t i) const
              Double_t GetFluctuation(Int_t i, Int_t j) const
              Double_t GetCorrelation(Int_t i, Int_t j) const
                Bool_t IsDataStored() const
               TClass* Class()
               TClass* IsA() const
                  void ShowMembers(TMemberInspector& insp, char* parent)
                  void Streamer(TBuffer& b)
                  void StreamerNVirtual(TBuffer& b)
          BrStatistics BrStatistics(BrStatistics&)

This page automatically generated by script docBrat by Christian Holm

Copyright ; 2002 BRAHMS Collaboration <brahmlib@rcf.rhic.bnl.gov>
Last Update on Wed Sep 11 04:53:16 2002 by

Validate HTML
Validate CSS