CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Attributes
Covariance Class Reference

#include <Histograms.h>

Public Member Functions

 Covariance ()
 
double covariance ()
 
void fill (const double &x, const double &y)
 
double getN ()
 

Protected Attributes

int N_
 
double productXY_
 
double sumX_
 
double sumY_
 

Detailed Description

This class can be used to compute the covariance between two input variables. The Fill method needs the two input variables. In the end the covariance method computes the covariance as: cov(x,y) = Sum_i(x_i*y_i)/N - x_mean*y_mean. Of course passing the same variable for x and y gives the variance of that variable.

Definition at line 1500 of file Histograms.h.

Constructor & Destructor Documentation

Covariance::Covariance ( )
inline

Definition at line 1503 of file Histograms.h.

1503  :
1504  productXY_(0),
1505  sumX_(0),
1506  sumY_(0),
1507  N_(0)
1508  {}
double productXY_
Definition: Histograms.h:1526
double sumY_
Definition: Histograms.h:1528
double sumX_
Definition: Histograms.h:1527

Member Function Documentation

double Covariance::covariance ( void  )
inline

Definition at line 1515 of file Histograms.h.

References N_, productXY_, sumX_, and sumY_.

Referenced by HCovarianceVSxy::Write().

1515  {
1516  if( N_ != 0 ) {
1517  double meanX = sumX_/N_;
1518  double meanY = sumY_/N_;
1519  // std::cout << "meanX*meanY = "<<meanX<<"*"<<meanY<< " = " << meanX*meanY << std::endl;
1520  return (productXY_/N_ - meanX*meanY);
1521  }
1522  return 0.;
1523  }
double productXY_
Definition: Histograms.h:1526
double sumY_
Definition: Histograms.h:1528
double sumX_
Definition: Histograms.h:1527
void Covariance::fill ( const double &  x,
const double &  y 
)
inline

Definition at line 1509 of file Histograms.h.

References N_, productXY_, sumX_, sumY_, x, and detailsBasic3DVector::y.

Referenced by HCovarianceVSxy::Fill().

1509  {
1510  productXY_ += x*y;
1511  sumX_ += x;
1512  sumY_ += y;
1513  ++N_;
1514  }
double productXY_
Definition: Histograms.h:1526
double sumY_
Definition: Histograms.h:1528
Definition: DDAxes.h:10
double sumX_
Definition: Histograms.h:1527
double Covariance::getN ( )
inline

Definition at line 1524 of file Histograms.h.

References N_.

1524 {return N_;}

Member Data Documentation

int Covariance::N_
protected

Definition at line 1529 of file Histograms.h.

Referenced by covariance(), fill(), and getN().

double Covariance::productXY_
protected

Definition at line 1526 of file Histograms.h.

Referenced by covariance(), and fill().

double Covariance::sumX_
protected

Definition at line 1527 of file Histograms.h.

Referenced by covariance(), and fill().

double Covariance::sumY_
protected

Definition at line 1528 of file Histograms.h.

Referenced by covariance(), and fill().