SNAP Library 2.0, Developer Reference
2013-05-13 16:33:57
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <xmath.h>
Public Member Functions | |
THist () | |
THist (const double &_MnVal, const double &_MxVal, const int &Buckets) | |
void | Add (const double &Val, const bool &OnlyInP) |
int | GetVals () const |
int | GetBuckets () const |
double | GetBucketMn (const int &BucketN) const |
double | GetBucketMx (const int &BucketN) const |
int | GetBucketVal (const int &BucketN) const |
double | GetBucketValPerc (const int &BucketN) const |
void | SaveStat (const TStr &ValNm, TSOut &FOut) const |
void | SaveTxt (const TStr &ValNm, const TStr &FNm) const |
Private Attributes | |
TFlt | MnVal |
TFlt | MxVal |
TIntV | BucketV |
TFlt | BucketSize |
TInt | Vals |
THist::THist | ( | ) | [inline] |
THist::THist | ( | const double & | _MnVal, |
const double & | _MxVal, | ||
const int & | Buckets | ||
) | [inline] |
void THist::Add | ( | const double & | Val, |
const bool & | OnlyInP | ||
) |
Definition at line 1270 of file xmath.cpp.
References BucketSize, BucketV, EAssert, TVec< TVal, TSizeTy >::Last(), TVec< TVal, TSizeTy >::Len(), MnVal, MxVal, and Vals.
{ // get bucket number const int BucketN = int(floor((Val - MnVal) / BucketSize)); if (OnlyInP) { // value should be inside EAssert(MnVal <= Val && Val <= MxVal); BucketV[BucketN]++; } else { // value does not need to be inside if (BucketN < 0) { BucketV[0]++; } else if (BucketN < BucketV.Len()) { BucketV[BucketN]++; } else { BucketV.Last()++; } } // for computing percentage Vals++; }
double THist::GetBucketMn | ( | const int & | BucketN | ) | const [inline] |
Definition at line 471 of file xmath.h.
References BucketSize, and MnVal.
{ return MnVal + BucketN * BucketSize; }
double THist::GetBucketMx | ( | const int & | BucketN | ) | const [inline] |
Definition at line 472 of file xmath.h.
References BucketSize, and MnVal.
{ return MnVal + (BucketN + 1) * BucketSize; }
int THist::GetBuckets | ( | ) | const [inline] |
int THist::GetBucketVal | ( | const int & | BucketN | ) | const [inline] |
double THist::GetBucketValPerc | ( | const int & | BucketN | ) | const [inline] |
int THist::GetVals | ( | ) | const [inline] |
void THist::SaveStat | ( | const TStr & | ValNm, |
TSOut & | FOut | ||
) | const |
Definition at line 1291 of file xmath.cpp.
References BucketSize, BucketV, TStr::Fmt(), TInt::GetStr(), TVec< TVal, TSizeTy >::Last(), TVec< TVal, TSizeTy >::Len(), TSOut::PutStrLn(), and Vals.
Referenced by SaveTxt().
{ FOut.PutStrLn("#" + ValNm + ": " + Vals.GetStr()); const int Buckets = BucketV.Len() - 1; for (int BucketN = 0; BucketN < Buckets; BucketN++) { FOut.PutStrLn(TStr::Fmt("%d-%d\t%d", BucketSize*BucketN, BucketSize*(BucketN+1), BucketV[BucketN]())); } if (BucketV.Last() > 0) { FOut.PutStrLn(TStr::Fmt("%d-\t%d", BucketSize*Buckets, BucketV.Last()())); } }
void THist::SaveTxt | ( | const TStr & | ValNm, |
const TStr & | FNm | ||
) | const [inline] |
Definition at line 478 of file xmath.h.
References SaveStat().
TFlt THist::BucketSize [private] |
Definition at line 459 of file xmath.h.
Referenced by Add(), GetBucketMn(), GetBucketMx(), and SaveStat().
TIntV THist::BucketV [private] |
Definition at line 458 of file xmath.h.
Referenced by Add(), GetBuckets(), GetBucketVal(), GetBucketValPerc(), and SaveStat().
TFlt THist::MnVal [private] |
Definition at line 456 of file xmath.h.
Referenced by Add(), GetBucketMn(), and GetBucketMx().
TFlt THist::MxVal [private] |
TInt THist::Vals [private] |
Definition at line 460 of file xmath.h.
Referenced by Add(), GetBucketValPerc(), GetVals(), and SaveStat().