]>
Commit | Line | Data |
---|---|---|
d88f97cc | 1 | #ifndef ALISAMPLE_H |
2 | #define ALISAMPLE_H | |
3da30618 | 3 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
4 | * See cxx source for full Copyright notice */ | |
5 | ||
6 | /* $Id$ */ | |
7 | ||
d88f97cc | 8 | /////////////////////////////////////////////////////////////////////////// |
9 | // Class AliSample | |
10 | // Perform statistics on various multi-dimensional data samples | |
11 | // A data sample can be filled using the "Enter" and/or "Remove" functions, | |
12 | // whereas the "Reset" function resets the complete sample to 'empty'. | |
13 | // The info which can be extracted from a certain data sample are the | |
14 | // sum, mean, variance, sigma, covariance and correlation. | |
15 | // The "Info" function provides all statistics data for a certain sample. | |
16 | // The variables for which these stat. parameters have to be calculated | |
17 | // are indicated by the index of the variable which is passed as an | |
18 | // argument to the various member functions. | |
19 | // The index convention for a data point (x,y) is : x=1 y=2 | |
20 | // | |
21 | // Example : | |
22 | // --------- | |
23 | // For an AliSample s a data point (x,y) can be entered as s.Enter(x,y) and | |
24 | // the mean_x can be obtained as s.GetMean(1) whereas the mean_y is obtained | |
25 | // via s.GetMean(2). | |
26 | // The correlation between x and y is available via s.GetCor(1,2). | |
27 | // The x-statistics are obtained via s.Info(1), y-statistics via s.Info(2), | |
28 | // and the covariance and correlation between x and y via s.Info(1,2). | |
29 | // All statistics of a sample are obtained via s.Info(). | |
30 | // | |
31 | //--- NvE 30-mar-1996 CERN Geneva | |
32 | /////////////////////////////////////////////////////////////////////////// | |
33 | ||
34 | #include <math.h> | |
35 | #include <iostream.h> | |
36 | ||
37 | #include "Rtypes.h" | |
38 | ||
39 | class AliSample | |
40 | { | |
41 | public: | |
42 | AliSample(); // Default constructor | |
43 | virtual ~AliSample(); // Default destructor | |
44 | void Reset(); // Reset complete statistics | |
45 | void Enter(Float_t x); // Enter value for 1-dim. sample | |
46 | void Remove(Float_t x); // Remove value from 1-dim. sample | |
47 | void Enter(Float_t x, Float_t y); // Enter value for 2-dim. sample | |
48 | void Remove(Float_t x, Float_t y); // Remove value from 2-dim. sample | |
49 | void Enter(Float_t x, Float_t y, Float_t z); // Enter value for 3-dim. sample | |
50 | void Remove(Float_t x, Float_t y, Float_t z); // Remove value from 3-dim. sample | |
51 | Int_t GetDimension(); // Provide dimension of the sample | |
52 | Int_t GetN(); // Provide the number of entries | |
53 | Float_t GetSum(Int_t i); // Provide sum for i-th variable | |
54 | Float_t GetMean(Int_t i); // Provide mean for i-th variable | |
55 | Float_t GetVar(Int_t i); // Provide variance for i-th variable | |
56 | Float_t GetSigma(Int_t i); // Standard deviation for i-th variable | |
57 | Float_t GetCov(Int_t i, Int_t j); // Covariance for i-th and j-th variable | |
58 | Float_t GetCor(Int_t i, Int_t j); // Correlation for i-th and j-th variable | |
59 | void Info(); // Stat. info for the complete sample | |
60 | void Info(Int_t i); // Stat. info for the i-th variable | |
61 | void Info(Int_t i, Int_t j); // Stat. info for i-th and j-th variable | |
62 | ||
63 | private: | |
64 | Int_t fDim; // Dimension of the sample | |
65 | Int_t fN; // Number of entries of the sample | |
66 | enum {fMaxdim=3}; // Maximum supported dimension | |
67 | char fNames[fMaxdim]; // Variable names i.e. X,Y,Z | |
68 | Float_t fSum[fMaxdim]; // Total sum for each variable | |
69 | Float_t fSum2[fMaxdim][fMaxdim]; // Total sum**2 for each variable | |
70 | void Compute(); // Compute the various quantities | |
71 | Float_t fMean[fMaxdim]; // Mean for each variable | |
72 | Float_t fVar[fMaxdim]; // Variation for each variable | |
73 | Float_t fSigma[fMaxdim]; // Standard deviation for each variable | |
74 | Float_t fCov[fMaxdim][fMaxdim]; // Covariances of pairs of variables | |
75 | Float_t fCor[fMaxdim][fMaxdim]; // Correlations of pairs of variables | |
76 | }; | |
77 | #endif |