// -*- mode: c++ -*- // // $Id: BrStatistics.h,v 1.7 2002/04/24 18:15:14 cholm Exp $ // #ifndef ROOT_BrStatistics #define ROOT_BrStatistics #ifndef ROOT_TObject #include "TObject.h" #endif #ifndef ROOT_TArrayD #include "TArrayD.h" #endif #ifndef ROOT_TH1 #include "TH1.h" #endif class TBrowser; class BrStatistics : public TObject { 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 public: BrStatistics(); BrStatistics(Int_t dimension, Bool_t storeData=kFALSE, Int_t size = 100); virtual ~BrStatistics(); 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); 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) { Draw("c color"); } virtual Int_t GetSampleSize() { return fM; } virtual Double_t GetMax(Int_t i) const; virtual const TArrayD& GetMaxArray() const { return fMax; } virtual Double_t GetCovariance(Int_t i, Int_t j) const; virtual const TArrayD& GetCovarianceArray() const { return fCovariance; } virtual Double_t GetAverage(Int_t i) const; virtual const TArrayD& GetAverageArray() const { return fAverage; } virtual Double_t GetMin(Int_t i) const; virtual const TArrayD& GetMinArray() const { return fMin; } virtual Double_t GetVariance(Int_t i) const; virtual Double_t GetFluctuation(Int_t i, Int_t j) const; virtual Double_t GetCorrelation(Int_t i, Int_t j) const; virtual Bool_t IsDataStored() const { return fDataStored; } virtual void Print(Option_t* option="balus") const; //*MENU* virtual void Draw(Option_t* option=""); //*MENU* virtual Double_t* GetRow(Int_t i) 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); ClassDef(BrStatistics,2) // Class for low-level statistics } ; //____________________________________________________________________ inline Double_t BrStatistics::GetCovariance(Int_t i, Int_t j) const { // return the i,j element of the covariance matrix // return fCovariance[i * fN + j]; // * fM / (fM - 1); return fCovariance.At(i * fN + j); // * fM / (fM - 1); } //____________________________________________________________________ inline Double_t BrStatistics::GetCorrelation(Int_t i, Int_t j) const { // return the i,j element of the correlation matrix return (i == j ? 1 : GetCovariance(i, j) / TMath::Sqrt(GetCovariance(i, i) * GetCovariance(j, j))); } //____________________________________________________________________ inline Double_t BrStatistics::GetFluctuation(Int_t i, Int_t j) const { // return the i,j element of the fluctuation matrix return (i == j ? GetCovariance(i, i) / GetAverage(i) : GetCovariance(i, j) / TMath::Sqrt(GetAverage(i) * GetAverage(j))); } //____________________________________________________________________ inline Double_t BrStatistics::GetMax(Int_t i) const { // return the maximum element of variable i // return fMax[i]; return fMax.At(i); } //____________________________________________________________________ inline Double_t BrStatistics::GetMin(Int_t i) const { // return the minimum element of variable i // return fMin[i]; return fMin.At(i); } //____________________________________________________________________ inline Double_t BrStatistics::GetAverage(Int_t i) const { // return the average element of variable i // return fAverage[i]; return fAverage.At(i); } //____________________________________________________________________ inline Double_t BrStatistics::GetVariance(Int_t i) const { // return the Variance element of variable i // return fCovariance[i * fN + i]; return fCovariance.At(i * fN + 1); } #endif // // EOF //