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
|
#include <xmath.h>
Public Member Functions | |
TCorr () | |
TCorr (const TFltV &ValV1, const TFltV &ValV2) | |
TCorr (TSIn &) | |
void | Save (TSOut &) |
TCorr & | operator= (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 > |
TCorr::TCorr | ( | ) | [inline] |
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)); }
double TCorr::GetCorrCf | ( | ) | const [inline] |
double TCorr::GetCorrCfPrb | ( | ) | const [inline] |
TStr TCorr::GetStr | ( | ) | const |
static PCorr TCorr::Load | ( | TSIn & | SIn | ) | [inline, static] |
static PCorr TCorr::New | ( | const TFltV & | ValV1, |
const TFltV & | ValV2 | ||
) | [inline, static] |
void TCorr::Save | ( | TSOut & | ) | [inline] |
double TCorr::CorrCf [private] |
double TCorr::CorrCfPrb [private] |
TCRef TCorr::CRef [private] |
double TCorr::FisherZ [private] |
int TCorr::ValVLen [private] |