SNAP Library 2.2, Developer Reference  2014-03-11 19:15:55
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TCorr Class Reference

#include <xmath.h>

Collaboration diagram for TCorr:

List of all members.

Public Member Functions

 TCorr ()
 TCorr (const TFltV &ValV1, const TFltV &ValV2)
 TCorr (TSIn &)
void Save (TSOut &)
TCorroperator= (const TCorr &)
double GetCorrCf () const
double GetCorrCfPrb () const
TStr GetStr () const

Static Public Member Functions

static PCorr New (const TFltV &ValV1, const TFltV &ValV2)
static PCorr Load (TSIn &SIn)

Private Attributes

TCRef CRef
int ValVLen
double CorrCf
double CorrCfPrb
double FisherZ

Friends

class TPt< TCorr >

Detailed Description

Definition at line 269 of file xmath.h.


Constructor & Destructor Documentation

TCorr::TCorr ( ) [inline]

Definition at line 276 of file xmath.h.

{}
TCorr::TCorr ( const TFltV ValV1,
const TFltV ValV2 
)

Definition at line 554 of file xmath.cpp.

References TSpecFunc::BetaI(), CorrCf, CorrCfPrb, FisherZ, IAssert, TVec< TVal, TSizeTy >::Len(), and ValVLen.

                                                  :
  ValVLen(ValV1.Len()), CorrCf(), CorrCfPrb(), FisherZ(){
  static const double TINY=1.0e-20;
  IAssert(ValV1.Len()==ValV2.Len());

  // calculate the means
  double MeanVal1=0; double MeanVal2=0;
  {for (int ValN=0; ValN<ValVLen; ValN++){
    MeanVal1+=ValV1[ValN]; MeanVal2+=ValV2[ValN];}}
  MeanVal1/=ValVLen; MeanVal2/=ValVLen;

  // calculate correlation coefficient
  double yt, xt;
  double syy=0.0; double sxy=0.0; double sxx=0.0;
  {for (int ValN=0; ValN<ValVLen; ValN++){
    xt=ValV1[ValN]-MeanVal1;
    yt=ValV2[ValN]-MeanVal2;
    sxx+=xt*xt;
    syy+=yt*yt;
    sxy+=xt*yt;
  }}
  if (sxx*syy==0){
    CorrCf=0; //** not in numerical recipes - check why (pojavi se, ko so same nicle)
  } else {
    CorrCf=sxy/sqrt(sxx*syy);
  }
  // calculate correlation coefficient significance level
  double df=ValVLen-2;
  double t=CorrCf*sqrt(df/((1.0-CorrCf+TINY)*(1.0+CorrCf+TINY)));
  CorrCfPrb=TSpecFunc::BetaI(0.5*df,0.5,df/(df+t*t));
  // calculate Fisher's Z transformation
  FisherZ=0.5*log((1.0+(CorrCf)+TINY)/(1.0-(CorrCf)+TINY));
}

Here is the call graph for this function:

TCorr::TCorr ( TSIn ) [inline]

Definition at line 280 of file xmath.h.

References Fail.

{Fail;}

Member Function Documentation

double TCorr::GetCorrCf ( ) const [inline]

Definition at line 286 of file xmath.h.

{return CorrCf;}
double TCorr::GetCorrCfPrb ( ) const [inline]

Definition at line 287 of file xmath.h.

{return CorrCfPrb;}
TStr TCorr::GetStr ( ) const
static PCorr TCorr::Load ( TSIn SIn) [inline, static]

Definition at line 281 of file xmath.h.

{return new TCorr(SIn);}
static PCorr TCorr::New ( const TFltV ValV1,
const TFltV ValV2 
) [inline, static]

Definition at line 278 of file xmath.h.

                                                          {
    return PCorr(new TCorr(ValV1, ValV2));}
TCorr& TCorr::operator= ( const TCorr ) [inline]

Definition at line 284 of file xmath.h.

References Fail.

{Fail; return *this;}
void TCorr::Save ( TSOut ) [inline]

Definition at line 282 of file xmath.h.

References Fail.

{Fail;}

Friends And Related Function Documentation

friend class TPt< TCorr > [friend]

Definition at line 269 of file xmath.h.


Member Data Documentation

double TCorr::CorrCf [private]

Definition at line 272 of file xmath.h.

Referenced by TCorr().

double TCorr::CorrCfPrb [private]

Definition at line 273 of file xmath.h.

Referenced by TCorr().

TCRef TCorr::CRef [private]

Definition at line 269 of file xmath.h.

double TCorr::FisherZ [private]

Definition at line 274 of file xmath.h.

Referenced by TCorr().

int TCorr::ValVLen [private]

Definition at line 271 of file xmath.h.

Referenced by TCorr().


The documentation for this class was generated from the following files: