SNAP Library 4.0, Developer Reference  2017-07-27 13:18:06
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TMom Class Reference

#include <xmath.h>

Collaboration diagram for TMom:

Public Member Functions

 TMom ()
 
 TMom (const TMom &Mom)
 
 TMom (const TFltV &_ValV)
 
 TMom (TSIn &SIn)
 
void Save (TSOut &SOut) const
 
TMomoperator= (const TMom &Mom)
 
bool operator== (const TMom &Mom) const
 
bool operator< (const TMom &Mom) const
 
void Def ()
 
bool IsDef () const
 
void Add (const TFlt &Val, const TFlt &Wgt=1)
 
double GetWgt () const
 
int GetVals () const
 
TFlt GetVal (const int &ValN) const
 
bool IsUsable () const
 
double GetMn () const
 
double GetMx () const
 
double GetExtent () const
 
double GetMean () const
 
double GetVari () const
 
double GetSDev () const
 
double GetSErr () const
 
double GetMedian () const
 
double GetQuart1 () const
 
double GetQuart3 () const
 
double GetMode () const
 
double GetDecile (const int &DecileN) const
 
double GetPercentile (const int &PercentileN) const
 
double GetByNm (const TStr &MomNm) const
 
TStr GetStrByNm (const TStr &MomNm, char *FmtStr=NULL) const
 
TStr GetStr (const char &SepCh=' ', const char &DelimCh=':', const bool &DecileP=true, const bool &PercentileP=true, const TStr &FmtStr="%g") const
 
TStr GetValVStr (const char &SepCh='\t', const bool &DecileP=true, const bool &PercentileP=true) const
 

Static Public Member Functions

static PMom New ()
 
static void NewV (TMomV &MomV, const int &Moms)
 
static void NewVV (TVVec< PMom > &MomVV, const int &XMoms, const int &YMoms)
 
static PMom New (const TFltV &ValV)
 
static PMom Load (TSIn &SIn)
 
static void DefV (TMomV &MomV)
 
static void DefVV (TVVec< PMom > &MomVV)
 
static bool IsUsableV (const TMomV &MomV)
 
static bool IsUsableVV (const TVVec< PMom > &MomVV)
 
static TStr GetNmVStr (const TStr &VarPfx, const char &SepCh='\t', const bool &DecileP=true, const bool &PercentileP=true)
 

Private Attributes

TCRef CRef
 
TBool DefP
 
TFltPrV ValWgtV
 
TFlt SumW
 
TFlt ValSumW
 
TInt Vals
 
TBool UsableP
 
TFlt UnusableVal
 
TFlt Mn
 
TFlt Mx
 
TFlt Mean
 
TFlt Vari
 
TFlt SDev
 
TFlt SErr
 
TFlt Median
 
TFlt Quart1
 
TFlt Quart3
 
TFlt Mode
 
TFltV DecileV
 
TFltV PercentileV
 

Friends

class TPt< TMom >
 

Detailed Description

Definition at line 129 of file xmath.h.

Constructor & Destructor Documentation

TMom::TMom ( )
inline

Definition at line 144 of file xmath.h.

144  :
145  DefP(false), ValWgtV(),
146  SumW(), ValSumW(), Vals(),
147  UsableP(false), UnusableVal(-1),
148  Mn(), Mx(),
149  Mean(), Vari(), SDev(), SErr(),
150  Median(), Quart1(), Quart3(), Mode(),
151  DecileV(), PercentileV(){}
TFlt SDev
Definition: xmath.h:138
TBool UsableP
Definition: xmath.h:135
TFlt Mx
Definition: xmath.h:137
TFlt Mode
Definition: xmath.h:140
TFlt Mn
Definition: xmath.h:137
TFlt Vari
Definition: xmath.h:138
TFlt SumW
Definition: xmath.h:133
TFlt ValSumW
Definition: xmath.h:133
TFlt Mean
Definition: xmath.h:138
TFlt Quart3
Definition: xmath.h:139
TFlt UnusableVal
Definition: xmath.h:136
TInt Vals
Definition: xmath.h:134
TFltPrV ValWgtV
Definition: xmath.h:132
TFlt SErr
Definition: xmath.h:138
TFlt Median
Definition: xmath.h:139
TBool DefP
Definition: xmath.h:131
TFltV PercentileV
Definition: xmath.h:142
TFltV DecileV
Definition: xmath.h:141
TFlt Quart1
Definition: xmath.h:139
TMom::TMom ( const TMom Mom)
inline

Definition at line 152 of file xmath.h.

152  :
153  DefP(Mom.DefP), ValWgtV(Mom.ValWgtV),
154  SumW(Mom.SumW), ValSumW(Mom.ValSumW), Vals(Mom.Vals),
156  Mn(Mom.Mn), Mx(Mom.Mx),
157  Mean(Mom.Mean), Vari(Mom.Vari), SDev(Mom.SDev), SErr(Mom.SErr),
158  Median(Mom.Median), Quart1(Mom.Quart1), Quart3(Mom.Quart3), Mode(Mom.Mode),
TFlt SDev
Definition: xmath.h:138
TBool UsableP
Definition: xmath.h:135
TFlt Mx
Definition: xmath.h:137
TFlt Mode
Definition: xmath.h:140
TFlt Mn
Definition: xmath.h:137
TFlt Vari
Definition: xmath.h:138
TFlt SumW
Definition: xmath.h:133
TFlt ValSumW
Definition: xmath.h:133
TFlt Mean
Definition: xmath.h:138
TFlt Quart3
Definition: xmath.h:139
TFlt UnusableVal
Definition: xmath.h:136
TInt Vals
Definition: xmath.h:134
TFltPrV ValWgtV
Definition: xmath.h:132
TFlt SErr
Definition: xmath.h:138
TFlt Median
Definition: xmath.h:139
TBool DefP
Definition: xmath.h:131
TFltV PercentileV
Definition: xmath.h:142
TFltV DecileV
Definition: xmath.h:141
TFlt Quart1
Definition: xmath.h:139
TMom::TMom ( const TFltV _ValV)

Definition at line 326 of file xmath.cpp.

References Add(), Def(), and TVec< TVal, TSizeTy >::Len().

326  :
327  //WgtV(_ValV.Len(), 0), ValV(_ValV.Len(), 0),
328  ValWgtV(_ValV.Len(), 0),
329  SumW(), ValSumW(),
330  UsableP(false), UnusableVal(-1),
331  Mn(), Mx(),
332  Mean(), Vari(), SDev(), SErr(),
333  Median(), Quart1(), Quart3(),
334  DecileV(), PercentileV(){
335  for (int ValN=0; ValN<_ValV.Len(); ValN++){Add(_ValV[ValN], 1);}
336  Def();
337 }
TFlt SDev
Definition: xmath.h:138
TBool UsableP
Definition: xmath.h:135
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TFlt Mx
Definition: xmath.h:137
TFlt Mn
Definition: xmath.h:137
void Add(const TFlt &Val, const TFlt &Wgt=1)
Definition: xmath.h:217
TFlt Vari
Definition: xmath.h:138
TFlt SumW
Definition: xmath.h:133
TFlt ValSumW
Definition: xmath.h:133
TFlt Mean
Definition: xmath.h:138
TFlt Quart3
Definition: xmath.h:139
TFlt UnusableVal
Definition: xmath.h:136
TFltPrV ValWgtV
Definition: xmath.h:132
TFlt SErr
Definition: xmath.h:138
TFlt Median
Definition: xmath.h:139
TFltV PercentileV
Definition: xmath.h:142
TFltV DecileV
Definition: xmath.h:141
void Def()
Definition: xmath.cpp:339
TFlt Quart1
Definition: xmath.h:139

Here is the call graph for this function:

TMom::TMom ( TSIn SIn)
inline

Definition at line 171 of file xmath.h.

171  :
172  DefP(SIn),
173  ValWgtV(SIn),
174  SumW(SIn), ValSumW(SIn), Vals(SIn),
175  UsableP(SIn), UnusableVal(SIn),
176  Mn(SIn), Mx(SIn),
177  Mean(SIn), Vari(SIn), SDev(SIn), SErr(SIn),
178  Median(SIn), Quart1(SIn), Quart3(SIn), Mode(SIn),
179  DecileV(SIn), PercentileV(SIn){}
TFlt SDev
Definition: xmath.h:138
TBool UsableP
Definition: xmath.h:135
TFlt Mx
Definition: xmath.h:137
TFlt Mode
Definition: xmath.h:140
TFlt Mn
Definition: xmath.h:137
TFlt Vari
Definition: xmath.h:138
TFlt SumW
Definition: xmath.h:133
TFlt ValSumW
Definition: xmath.h:133
TFlt Mean
Definition: xmath.h:138
TFlt Quart3
Definition: xmath.h:139
TFlt UnusableVal
Definition: xmath.h:136
TInt Vals
Definition: xmath.h:134
TFltPrV ValWgtV
Definition: xmath.h:132
TFlt SErr
Definition: xmath.h:138
TFlt Median
Definition: xmath.h:139
TBool DefP
Definition: xmath.h:131
TFltV PercentileV
Definition: xmath.h:142
TFltV DecileV
Definition: xmath.h:141
TFlt Quart1
Definition: xmath.h:139

Member Function Documentation

void TMom::Add ( const TFlt Val,
const TFlt Wgt = 1 
)
inline

Definition at line 217 of file xmath.h.

References Assert.

Referenced by TGStat::AvgGStat(), TSnap::GetAnfEffDiam(), TLocClustStat::GetCurveStat(), TLocClustStat::TCutInfo::GetFracDegOut(), TNcpGraphsBase::PlotAvgNcp(), TTimeNet::PlotEffDiam(), TTimeNet::PlotMedianDegOverTm(), TTimeNet::PlotMissingPast(), TGStat::TakeDiam(), and TMom().

217  {Assert(!DefP);
218  ValWgtV.Add(TFltPr(Val, Wgt)); SumW+=Wgt; ValSumW+=Wgt*Val; Vals++;}
#define Assert(Cond)
Definition: bd.h:251
TFlt SumW
Definition: xmath.h:133
TFlt ValSumW
Definition: xmath.h:133
TPair< TFlt, TFlt > TFltPr
Definition: ds.h:99
TInt Vals
Definition: xmath.h:134
TFltPrV ValWgtV
Definition: xmath.h:132
TBool DefP
Definition: xmath.h:131
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602

Here is the caller graph for this function:

void TMom::Def ( )

Definition at line 339 of file xmath.cpp.

References THash< TKey, TDat, THashFunc >::AddDat(), TVec< TVal, TSizeTy >::Clr(), DecileV, DefP, TVec< TVal, TSizeTy >::Gen(), THash< TKey, TDat, THashFunc >::GetKey(), IAssert, THash< TKey, TDat, THashFunc >::Len(), TVec< TVal, TSizeTy >::Len(), Mean, Median, Mn, TFlt::Mn, Mode, Mx, PercentileV, Quart1, Quart3, SDev, SErr, TVec< TVal, TSizeTy >::Sort(), TMath::Sqr(), SumW, UsableP, ValSumW, ValWgtV, and Vari.

Referenced by TGnuPlot::AddPlot(), TGStat::AvgGStat(), TSnap::GetAnfEffDiam(), TLocClustStat::GetCurveStat(), TLocClustStat::TCutInfo::GetFracDegOut(), TTimeNet::PlotEffDiam(), TTimeNet::PlotMedianDegOverTm(), TTimeNet::PlotMissingPast(), TGnuPlot::PlotValMomH(), TGStat::TakeDiam(), and TMom().

339  {
340  IAssert(!DefP); DefP=true;
341  UsableP=(SumW>0)&&(ValWgtV.Len()>0);
342  if (UsableP){
343  // Mn, Mx
344  Mn=ValWgtV[0].Val1;
345  Mx=ValWgtV[0].Val1;
346  // Mean, Variance (Mn, Mx), Standard-Error
347  Mean=ValSumW/SumW;
348  Vari=0;
349  if (ValWgtV.Len()>1){
350  for (int ValN=0; ValN<ValWgtV.Len(); ValN++){
351  const double Val=ValWgtV[ValN].Val1;
352  Vari+=ValWgtV[ValN].Val2*TMath::Sqr(Val-Mean);
353  if (Val<Mn){Mn=Val;}
354  if (Val>Mx){Mx=Val;}
355  }
356  Vari=Vari/SumW;
357  // SErr=sqrt(Vari/(ValWgtV.Len()*(ValWgtV.Len()-1))); //J: This seems to be wrong
358  if (Vari > 0.0 && SumW > 0.0) {
359  SErr=sqrt(double(Vari))/sqrt(double(SumW)); //J: This seems to ok: StdDev/sqrt(N)
360  } else { SErr = Mx; } // some big number
361  }
362  // Standard-Deviation
363  SDev=sqrt(double(Vari));
364  // Median
365  ValWgtV.Sort();
366  double CurSumW = 0;
367  for (int ValN=0; ValN<ValWgtV.Len(); ValN++){
368  CurSumW += ValWgtV[ValN].Val2;
369  if (CurSumW > 0.5*SumW) {
370  Median = ValWgtV[ValN].Val1; break; }
371  else if (CurSumW == 0.5*SumW) {
372  Median = 0.5 * (ValWgtV[ValN].Val1+ValWgtV[ValN+1].Val1); break; }
373  }
374  // Quartile-1 and Quartile-3
376  CurSumW = 0;
377  for (int ValN=0; ValN<ValWgtV.Len(); ValN++){
378  CurSumW += ValWgtV[ValN].Val2;
379  if (Quart1==TFlt::Mn) {
380  if (CurSumW > 0.25*SumW) { Quart1 = ValWgtV[ValN].Val1; }
381  //else if (CurSumW == 0.25*SumW) { Quart1 = 0.5 * (ValWgtV[ValN].Val1+ValWgtV[ValN+1].Val1); }
382  }
383  if (Quart3==TFlt::Mn) {
384  if (CurSumW > 0.75*SumW) { Quart3 = ValWgtV[ValN].Val1; }
385  //else if (CurSumW == 0.75*SumW) { Quart3 = 0.5 * (ValWgtV[ValN].Val1+ValWgtV[ValN+1].Val1); }
386  }
387  }
388  // Mode (value with max total weight)
389  THash<TFlt, TFlt> ValWgtH;
390  for (int i = 0; i < ValWgtV.Len(); i++) {
391  ValWgtH.AddDat(ValWgtV[i].Val1) += ValWgtV[i].Val2; }
392  Mode = TFlt::Mn; double MxWgt=TFlt::Mn;
393  for (int v = 0; v < ValWgtH.Len(); v++) {
394  if (ValWgtH[v] > MxWgt) { MxWgt=ValWgtH[v]; Mode=ValWgtH.GetKey(v); }
395  }
396  // Deciles & Percentiles
397  CurSumW = 0;
398  int DecileN = 1, PercentileN = 1;
399  DecileV.Gen(11); PercentileV.Gen(101);
400  DecileV[0]=Mn; DecileV[10]=Mx;
401  PercentileV[0]=Mn; PercentileV[100]=Mx;
402  for (int ValN=0; ValN<ValWgtV.Len(); ValN++){
403  CurSumW += ValWgtV[ValN].Val2;
404  if (CurSumW > SumW*DecileN*0.1) {
405  DecileV[DecileN] = ValWgtV[ValN].Val1; DecileN++; }
406  if (CurSumW > SumW*PercentileN*0.01) {
407  PercentileV[PercentileN] = ValWgtV[ValN].Val1; PercentileN++; }
408  }
409  }
410  ValWgtV.Clr();
411 }
#define IAssert(Cond)
Definition: bd.h:262
TFlt SDev
Definition: xmath.h:138
TBool UsableP
Definition: xmath.h:135
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TFlt Mx
Definition: xmath.h:137
TFlt Mode
Definition: xmath.h:140
static double Sqr(const double &x)
Definition: xmath.h:12
TFlt Mn
Definition: xmath.h:137
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:1022
void Sort(const bool &Asc=true)
Sorts the elements of the vector.
Definition: ds.h:1318
TFlt Vari
Definition: xmath.h:138
TFlt SumW
Definition: xmath.h:133
TFlt ValSumW
Definition: xmath.h:133
TFlt Mean
Definition: xmath.h:138
TFlt Quart3
Definition: xmath.h:139
Definition: hash.h:97
TFltPrV ValWgtV
Definition: xmath.h:132
TFlt SErr
Definition: xmath.h:138
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:523
TFlt Median
Definition: xmath.h:139
TBool DefP
Definition: xmath.h:131
TFltV PercentileV
Definition: xmath.h:142
int Len() const
Definition: hash.h:228
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
TFltV DecileV
Definition: xmath.h:141
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:252
static const double Mn
Definition: dt.h:1387
TFlt Quart1
Definition: xmath.h:139

Here is the call graph for this function:

Here is the caller graph for this function:

static void TMom::DefV ( TMomV MomV)
inlinestatic

Definition at line 208 of file xmath.h.

References TVec< TVal, TSizeTy >::Len().

208  {
209  for (int MomN=0; MomN<MomV.Len(); MomN++){MomV[MomN]->Def();}}
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575

Here is the call graph for this function:

static void TMom::DefVV ( TVVec< PMom > &  MomVV)
inlinestatic

Definition at line 210 of file xmath.h.

References TVVec< TVal, TSizeTy >::At(), TVVec< TVal, TSizeTy >::GetXDim(), and TVVec< TVal, TSizeTy >::GetYDim().

210  {
211  for (int XMomN=0; XMomN<MomVV.GetXDim(); XMomN++){
212  for (int YMomN=0; YMomN<MomVV.GetYDim(); YMomN++){
213  MomVV.At(XMomN, YMomN)->Def();}}}
TSizeTy GetYDim() const
Definition: ds.h:2250
TSizeTy GetXDim() const
Definition: ds.h:2249
const TVal & At(const TSizeTy &X, const TSizeTy &Y) const
Definition: ds.h:2255

Here is the call graph for this function:

double TMom::GetByNm ( const TStr MomNm) const

Definition at line 415 of file xmath.cpp.

References Fail, GetDecile(), GetMean(), GetMedian(), GetQuart1(), GetQuart3(), GetSDev(), GetSErr(), and GetVari().

Referenced by GetStrByNm().

415  {
416  if (MomNm=="Mean"){return GetMean();}
417  else if (MomNm=="Vari"){return GetVari();}
418  else if (MomNm=="SDev"){return GetSDev();}
419  else if (MomNm=="SErr"){return GetSErr();}
420  else if (MomNm=="Median"){return GetMedian();}
421  else if (MomNm=="Quart1"){return GetQuart1();}
422  else if (MomNm=="Quart3"){return GetQuart3();}
423  else if (MomNm=="Decile0"){return GetDecile(0);}
424  else if (MomNm=="Decile1"){return GetDecile(1);}
425  else if (MomNm=="Decile2"){return GetDecile(2);}
426  else if (MomNm=="Decile3"){return GetDecile(3);}
427  else if (MomNm=="Decile4"){return GetDecile(4);}
428  else if (MomNm=="Decile5"){return GetDecile(5);}
429  else if (MomNm=="Decile6"){return GetDecile(6);}
430  else if (MomNm=="Decile7"){return GetDecile(7);}
431  else if (MomNm=="Decile8"){return GetDecile(8);}
432  else if (MomNm=="Decile9"){return GetDecile(9);}
433  else if (MomNm=="Decile10"){return GetDecile(10);}
434  else {Fail; return 0;}
435 }
double GetMedian() const
Definition: xmath.h:244
#define Fail
Definition: bd.h:238
double GetSDev() const
Definition: xmath.h:242
double GetSErr() const
Definition: xmath.h:243
double GetQuart3() const
Definition: xmath.h:246
double GetMean() const
Definition: xmath.h:240
double GetQuart1() const
Definition: xmath.h:245
double GetVari() const
Definition: xmath.h:241
double GetDecile(const int &DecileN) const
Definition: xmath.h:248

Here is the call graph for this function:

Here is the caller graph for this function:

double TMom::GetDecile ( const int &  DecileN) const
inline

Definition at line 248 of file xmath.h.

References Assert.

Referenced by GetByNm(), TLocClustStat::GetCurveStat(), TLocClustStat::TCutInfo::GetFracDegOut(), GetStr(), and GetValVStr().

248  {
249  Assert(DefP&&UsableP); return DecileV[DecileN];}
TBool UsableP
Definition: xmath.h:135
#define Assert(Cond)
Definition: bd.h:251
TBool DefP
Definition: xmath.h:131
TFltV DecileV
Definition: xmath.h:141

Here is the caller graph for this function:

double TMom::GetExtent ( ) const
inline

Definition at line 239 of file xmath.h.

References Assert.

239 {Assert(DefP&&UsableP); return Mx-Mn;}
TBool UsableP
Definition: xmath.h:135
TFlt Mx
Definition: xmath.h:137
TFlt Mn
Definition: xmath.h:137
#define Assert(Cond)
Definition: bd.h:251
TBool DefP
Definition: xmath.h:131
double TMom::GetMean ( ) const
inline
double TMom::GetMedian ( ) const
inline

Definition at line 244 of file xmath.h.

References Assert.

Referenced by TGnuPlot::AddPlot(), GetByNm(), TLocClustStat::GetCurveStat(), TLocClustStat::TCutInfo::GetFracDegOut(), GetStr(), GetValVStr(), TTimeNet::PlotMedianDegOverTm(), and TGnuPlot::PlotValMomH().

244 {Assert(DefP&&UsableP); return Median;}
TBool UsableP
Definition: xmath.h:135
#define Assert(Cond)
Definition: bd.h:251
TFlt Median
Definition: xmath.h:139
TBool DefP
Definition: xmath.h:131

Here is the caller graph for this function:

double TMom::GetMn ( ) const
inline

Definition at line 237 of file xmath.h.

References Assert.

Referenced by TGnuPlot::AddPlot(), TLocClustStat::GetCurveStat(), GetStr(), GetValVStr(), and TGnuPlot::PlotValMomH().

237 {Assert(DefP&&UsableP); return Mn;}
TBool UsableP
Definition: xmath.h:135
TFlt Mn
Definition: xmath.h:137
#define Assert(Cond)
Definition: bd.h:251
TBool DefP
Definition: xmath.h:131

Here is the caller graph for this function:

double TMom::GetMode ( ) const
inline

Definition at line 247 of file xmath.h.

References Assert.

247 {Assert(DefP&&UsableP); return Mode;}
TBool UsableP
Definition: xmath.h:135
TFlt Mode
Definition: xmath.h:140
#define Assert(Cond)
Definition: bd.h:251
TBool DefP
Definition: xmath.h:131
double TMom::GetMx ( ) const
inline

Definition at line 238 of file xmath.h.

References Assert.

Referenced by TGnuPlot::AddPlot(), TLocClustStat::GetCurveStat(), TLocClustStat::TCutInfo::GetFracDegOut(), GetStr(), GetValVStr(), and TGnuPlot::PlotValMomH().

238 {Assert(DefP&&UsableP); return Mx;}
TBool UsableP
Definition: xmath.h:135
TFlt Mx
Definition: xmath.h:137
#define Assert(Cond)
Definition: bd.h:251
TBool DefP
Definition: xmath.h:131

Here is the caller graph for this function:

TStr TMom::GetNmVStr ( const TStr VarPfx,
const char &  SepCh = '\t',
const bool &  DecileP = true,
const bool &  PercentileP = true 
)
static

Definition at line 486 of file xmath.cpp.

References TInt::GetStr().

487  {
488  TChA ChA;
489  ChA+=VarPfx; ChA+="Vals"; ChA+=SepCh;
490  ChA+=VarPfx; ChA+="Min"; ChA+=SepCh;
491  ChA+=VarPfx; ChA+="Max"; ChA+=SepCh;
492  ChA+=VarPfx; ChA+="Mean"; ChA+=SepCh;
493  //ChA+=VarPfx; ChA+="Vari"; ChA+=SepCh;
494  ChA+=VarPfx; ChA+="SDev"; ChA+=SepCh;
495  //ChA+=VarPfx; ChA+="SErr"; ChA+=SepCh;
496  ChA+=VarPfx; ChA+="Quart1"; ChA+=SepCh;
497  ChA+=VarPfx; ChA+="Median"; ChA+=SepCh;
498  ChA+=VarPfx; ChA+="Quart3";
499  if (DecileP){
500  ChA+=SepCh;
501  for (int DecileN=0; DecileN<=10; DecileN++){
502  ChA+=VarPfx; ChA+="Dec"; ChA+=TInt::GetStr(DecileN);
503  if (DecileN<10){ChA+=SepCh;}
504  }
505  }
506  if (PercentileP){
507  ChA+=SepCh;
508  for (int PercentileN=0; PercentileN<=100; PercentileN++){
509  ChA+=VarPfx; ChA+="Per"; ChA+=TInt::GetStr(PercentileN);
510  if (PercentileN<100){ChA+=SepCh;}
511  }
512  }
513  return ChA;
514 }
TStr GetStr() const
Definition: dt.h:1197
Definition: dt.h:201

Here is the call graph for this function:

double TMom::GetPercentile ( const int &  PercentileN) const
inline

Definition at line 250 of file xmath.h.

References Assert.

Referenced by GetStr(), and GetValVStr().

250  {
251  Assert(DefP&&UsableP); return PercentileV[PercentileN];}
TBool UsableP
Definition: xmath.h:135
#define Assert(Cond)
Definition: bd.h:251
TBool DefP
Definition: xmath.h:131
TFltV PercentileV
Definition: xmath.h:142

Here is the caller graph for this function:

double TMom::GetQuart1 ( ) const
inline

Definition at line 245 of file xmath.h.

References Assert.

Referenced by GetByNm(), GetStr(), and GetValVStr().

245 {Assert(DefP&&UsableP); return Quart1;}
TBool UsableP
Definition: xmath.h:135
#define Assert(Cond)
Definition: bd.h:251
TBool DefP
Definition: xmath.h:131
TFlt Quart1
Definition: xmath.h:139

Here is the caller graph for this function:

double TMom::GetQuart3 ( ) const
inline

Definition at line 246 of file xmath.h.

References Assert.

Referenced by GetByNm(), GetStr(), and GetValVStr().

246 {Assert(DefP&&UsableP); return Quart3;}
TBool UsableP
Definition: xmath.h:135
#define Assert(Cond)
Definition: bd.h:251
TFlt Quart3
Definition: xmath.h:139
TBool DefP
Definition: xmath.h:131

Here is the caller graph for this function:

double TMom::GetSDev ( ) const
inline

Definition at line 242 of file xmath.h.

References Assert.

Referenced by TGnuPlot::AddPlot(), GetByNm(), GetStr(), GetValVStr(), TTimeNet::PlotEffDiam(), TTimeNet::PlotMissingPast(), TGnuPlot::PlotValMomH(), TGStat::TakeDiam(), and TSnap::TestAnf().

242 {Assert(DefP&&UsableP); return SDev;}
TFlt SDev
Definition: xmath.h:138
TBool UsableP
Definition: xmath.h:135
#define Assert(Cond)
Definition: bd.h:251
TBool DefP
Definition: xmath.h:131

Here is the caller graph for this function:

double TMom::GetSErr ( ) const
inline

Definition at line 243 of file xmath.h.

References Assert.

Referenced by GetByNm().

243 {Assert(DefP&&UsableP); return SErr;}
TBool UsableP
Definition: xmath.h:135
#define Assert(Cond)
Definition: bd.h:251
TFlt SErr
Definition: xmath.h:138
TBool DefP
Definition: xmath.h:131

Here is the caller graph for this function:

TStr TMom::GetStr ( const char &  SepCh = ' ',
const char &  DelimCh = ':',
const bool &  DecileP = true,
const bool &  PercentileP = true,
const TStr FmtStr = "%g" 
) const

Definition at line 449 of file xmath.cpp.

References TStr::CStr(), GetDecile(), GetMean(), GetMedian(), GetMn(), GetMx(), GetPercentile(), GetQuart1(), GetQuart3(), GetSDev(), TInt::GetStr(), TFlt::GetStr(), GetVals(), and IsUsable().

451  {
452  TChA ChA;
453  if (IsUsable()){
454  ChA+="["; ChA+=SepCh;
455  ChA+="Vals"; ChA+=DelimCh; ChA+=TInt::GetStr(GetVals()); ChA+=SepCh;
456  ChA+="Min"; ChA+=DelimCh; ChA+=TFlt::GetStr(GetMn(), FmtStr.CStr()); ChA+=SepCh;
457  ChA+="Max"; ChA+=DelimCh; ChA+=TFlt::GetStr(GetMx(), FmtStr.CStr()); ChA+=SepCh;
458  ChA+="Mean"; ChA+=DelimCh; ChA+=TFlt::GetStr(GetMean(), FmtStr.CStr()); ChA+=SepCh;
459  //ChA+="Vari"; ChA+=DelimCh; ChA+=TFlt::GetStr(GetVari(), FmtStr.CStr()); ChA+=SepCh;
460  ChA+="SDev"; ChA+=DelimCh; ChA+=TFlt::GetStr(GetSDev(), FmtStr.CStr()); ChA+=SepCh;
461  //ChA+="SErr"; ChA+=DelimCh; ChA+=TFlt::GetStr(GetSErr(), FmtStr.CStr()); ChA+=SepCh;
462  ChA+="Quart1"; ChA+=DelimCh; ChA+=TFlt::GetStr(GetQuart1(), FmtStr.CStr()); ChA+=SepCh;
463  ChA+="Median"; ChA+=DelimCh; ChA+=TFlt::GetStr(GetMedian(), FmtStr.CStr()); ChA+=SepCh;
464  ChA+="Quart3"; ChA+=DelimCh; ChA+=TFlt::GetStr(GetQuart3(), FmtStr.CStr()); ChA+=SepCh;
465  if (DecileP){
466  for (int DecileN=0; DecileN<=10; DecileN++){
467  ChA+="Dec"; ChA+=TInt::GetStr(DecileN);
468  ChA+=DelimCh; ChA+=TFlt::GetStr(GetDecile(DecileN), FmtStr.CStr());
469  ChA+=SepCh;
470  }
471  }
472  if (PercentileP){
473  for (int PercentileN=0; PercentileN<=100; PercentileN++){
474  ChA+="Per"; ChA+=TInt::GetStr(PercentileN);
475  ChA+=DelimCh; ChA+=TFlt::GetStr(GetPercentile(PercentileN), FmtStr.CStr());
476  ChA+=SepCh;
477  }
478  }
479  ChA+="]";
480  } else {
481  ChA="[Unusable]";
482  }
483  return ChA;
484 }
TStr GetStr() const
Definition: dt.h:1197
double GetMedian() const
Definition: xmath.h:244
int GetVals() const
Definition: xmath.h:220
double GetSDev() const
Definition: xmath.h:242
bool IsUsable() const
Definition: xmath.h:225
double GetMx() const
Definition: xmath.h:238
double GetPercentile(const int &PercentileN) const
Definition: xmath.h:250
double GetQuart3() const
Definition: xmath.h:246
Definition: dt.h:201
double GetMean() const
Definition: xmath.h:240
double GetQuart1() const
Definition: xmath.h:245
double GetDecile(const int &DecileN) const
Definition: xmath.h:248
TStr GetStr() const
Definition: dt.h:1459
char * CStr()
Definition: dt.h:476
double GetMn() const
Definition: xmath.h:237

Here is the call graph for this function:

TStr TMom::GetStrByNm ( const TStr MomNm,
char *  FmtStr = NULL 
) const

Definition at line 437 of file xmath.cpp.

References GetByNm(), TFlt::GetStr(), and IsUsable().

437  {
438  if (IsUsable()){
439  if (FmtStr==NULL){
440  return TFlt::GetStr(GetByNm(MomNm));
441  } else {
442  return TFlt::GetStr(GetByNm(MomNm), FmtStr);
443  }
444  } else {
445  return "X";
446  }
447 }
bool IsUsable() const
Definition: xmath.h:225
TStr GetStr() const
Definition: dt.h:1459
double GetByNm(const TStr &MomNm) const
Definition: xmath.cpp:415

Here is the call graph for this function:

TFlt TMom::GetVal ( const int &  ValN) const
inline

Definition at line 221 of file xmath.h.

References IAssert.

221 {IAssert(!IsDef()); return ValWgtV[ValN].Val1;}
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: xmath.h:214
TFltPrV ValWgtV
Definition: xmath.h:132
int TMom::GetVals ( ) const
inline

Definition at line 220 of file xmath.h.

Referenced by TGnuPlot::AddPlot(), TGStat::AvgGStat(), GetStr(), GetValVStr(), and TGnuPlot::PlotValMomH().

220 {return Vals;}
TInt Vals
Definition: xmath.h:134

Here is the caller graph for this function:

TStr TMom::GetValVStr ( const char &  SepCh = '\t',
const bool &  DecileP = true,
const bool &  PercentileP = true 
) const

Definition at line 516 of file xmath.cpp.

References GetDecile(), GetMean(), GetMedian(), GetMn(), GetMx(), GetPercentile(), GetQuart1(), GetQuart3(), GetSDev(), TInt::GetStr(), TFlt::GetStr(), GetVals(), IsUsable(), and Vals.

517  {
518  TChA ChA;
519  if (IsUsable()){
520  ChA+=TInt::GetStr(GetVals()); ChA+=SepCh;
521  ChA+=TFlt::GetStr(GetMn()); ChA+=SepCh;
522  ChA+=TFlt::GetStr(GetMx()); ChA+=SepCh;
523  ChA+=TFlt::GetStr(GetMean()); ChA+=SepCh;
524  //ChA+=TFlt::GetStr(GetVari()); ChA+=SepCh;
525  ChA+=TFlt::GetStr(GetSDev()); ChA+=SepCh;
526  //ChA+=TFlt::GetStr(GetSErr()); ChA+=SepCh;
527  ChA+=TFlt::GetStr(GetQuart1()); ChA+=SepCh;
528  ChA+=TFlt::GetStr(GetMedian()); ChA+=SepCh;
529  ChA+=TFlt::GetStr(GetQuart3()); ChA+=SepCh;
530  if (DecileP){
531  for (int DecileN=0; DecileN<=10; DecileN++){
532  ChA+=TFlt::GetStr(GetDecile(DecileN)); ChA+=SepCh;
533  }
534  }
535  if (PercentileP){
536  for (int PercentileN=0; PercentileN<=100; PercentileN++){
537  ChA+=TFlt::GetStr(GetPercentile(PercentileN)); ChA+=SepCh;
538  }
539  }
540  } else {
541  int Vals=8;
542  if (DecileP){Vals+=11;}
543  if (PercentileP){Vals+=101;}
544  for (int ValN=0; ValN<Vals; ValN++){
545  ChA="[Unusable]";
546  if (ValN<Vals-1){ChA+=SepCh;}
547  }
548  }
549  return ChA;
550 }
TStr GetStr() const
Definition: dt.h:1197
double GetMedian() const
Definition: xmath.h:244
int GetVals() const
Definition: xmath.h:220
double GetSDev() const
Definition: xmath.h:242
bool IsUsable() const
Definition: xmath.h:225
double GetMx() const
Definition: xmath.h:238
double GetPercentile(const int &PercentileN) const
Definition: xmath.h:250
double GetQuart3() const
Definition: xmath.h:246
Definition: dt.h:201
TInt Vals
Definition: xmath.h:134
double GetMean() const
Definition: xmath.h:240
double GetQuart1() const
Definition: xmath.h:245
double GetDecile(const int &DecileN) const
Definition: xmath.h:248
TStr GetStr() const
Definition: dt.h:1459
double GetMn() const
Definition: xmath.h:237

Here is the call graph for this function:

double TMom::GetVari ( ) const
inline

Definition at line 241 of file xmath.h.

References Assert.

Referenced by GetByNm().

241 {Assert(DefP&&UsableP); return Vari;}
TBool UsableP
Definition: xmath.h:135
#define Assert(Cond)
Definition: bd.h:251
TFlt Vari
Definition: xmath.h:138
TBool DefP
Definition: xmath.h:131

Here is the caller graph for this function:

double TMom::GetWgt ( ) const
inline

Definition at line 219 of file xmath.h.

219 {return SumW;}
TFlt SumW
Definition: xmath.h:133
bool TMom::IsDef ( ) const
inline

Definition at line 214 of file xmath.h.

Referenced by TGnuPlot::AddPlot(), and TGnuPlot::PlotValMomH().

214 {return DefP;}
TBool DefP
Definition: xmath.h:131

Here is the caller graph for this function:

bool TMom::IsUsable ( ) const
inline

Definition at line 225 of file xmath.h.

References Assert.

Referenced by TGStat::AvgGStat(), GetStr(), GetStrByNm(), and GetValVStr().

225 {Assert(DefP); return UsableP;}
TBool UsableP
Definition: xmath.h:135
#define Assert(Cond)
Definition: bd.h:251
TBool DefP
Definition: xmath.h:131

Here is the caller graph for this function:

static bool TMom::IsUsableV ( const TMomV MomV)
inlinestatic

Definition at line 226 of file xmath.h.

References TVec< TVal, TSizeTy >::Len().

226  {
227  for (int MomN=0; MomN<MomV.Len(); MomN++){
228  if (!MomV[MomN]->IsUsable()){return false;}}
229  return true;}
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
bool IsUsable() const
Definition: xmath.h:225

Here is the call graph for this function:

static bool TMom::IsUsableVV ( const TVVec< PMom > &  MomVV)
inlinestatic

Definition at line 230 of file xmath.h.

References TVVec< TVal, TSizeTy >::At(), TVVec< TVal, TSizeTy >::GetXDim(), and TVVec< TVal, TSizeTy >::GetYDim().

230  {
231  for (int XMomN=0; XMomN<MomVV.GetXDim(); XMomN++){
232  for (int YMomN=0; YMomN<MomVV.GetYDim(); YMomN++){
233  if (!MomVV.At(XMomN, YMomN)->IsUsable()){return false;}}}
234  return true;}
TSizeTy GetYDim() const
Definition: ds.h:2250
TSizeTy GetXDim() const
Definition: ds.h:2249
const TVal & At(const TSizeTy &X, const TSizeTy &Y) const
Definition: ds.h:2255

Here is the call graph for this function:

static PMom TMom::Load ( TSIn SIn)
inlinestatic

Definition at line 180 of file xmath.h.

180 {return new TMom(SIn);}
TMom()
Definition: xmath.h:144
static PMom TMom::New ( )
inlinestatic

Definition at line 160 of file xmath.h.

Referenced by TStatTest::TTest().

160 {return PMom(new TMom());}
TMom()
Definition: xmath.h:144
TPt< TMom > PMom
Definition: xmath.h:129

Here is the caller graph for this function:

static PMom TMom::New ( const TFltV ValV)
inlinestatic

Definition at line 169 of file xmath.h.

169  {
170  return PMom(new TMom(ValV));}
TMom()
Definition: xmath.h:144
TPt< TMom > PMom
Definition: xmath.h:129
static void TMom::NewV ( TMomV MomV,
const int &  Moms 
)
inlinestatic

Definition at line 161 of file xmath.h.

References TVec< TVal, TSizeTy >::Gen().

161  {
162  MomV.Gen(Moms); for (int MomN=0; MomN<Moms; MomN++){MomV[MomN]=New();}}
static PMom New()
Definition: xmath.h:160
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:523

Here is the call graph for this function:

static void TMom::NewVV ( TVVec< PMom > &  MomVV,
const int &  XMoms,
const int &  YMoms 
)
inlinestatic

Definition at line 163 of file xmath.h.

References TVVec< TVal, TSizeTy >::At(), and TVVec< TVal, TSizeTy >::Gen().

163  {
164  MomVV.Gen(XMoms, YMoms);
165  for (int XMomN=0; XMomN<XMoms; XMomN++){
166  for (int YMomN=0; YMomN<YMoms; YMomN++){
167  MomVV.At(XMomN, YMomN)=New();}}}
static PMom New()
Definition: xmath.h:160
void Gen(const TSizeTy &_XDim, const TSizeTy &_YDim)
Definition: ds.h:2246
const TVal & At(const TSizeTy &X, const TSizeTy &Y) const
Definition: ds.h:2255

Here is the call graph for this function:

bool TMom::operator< ( const TMom Mom) const
inline

Definition at line 203 of file xmath.h.

References Vals.

203  {
204  return Vals<Mom.Vals;}
TInt Vals
Definition: xmath.h:134
TMom& TMom::operator= ( const TMom Mom)
inline

Definition at line 191 of file xmath.h.

References Assert, DecileV, DefP, Mean, Median, Mn, Mode, Mx, PercentileV, Quart1, Quart3, SDev, SErr, SumW, UnusableVal, UsableP, Vals, ValSumW, ValWgtV, and Vari.

191  {
192  Assert(!DefP); DefP=Mom.DefP;
193  ValWgtV=Mom.ValWgtV;
194  SumW=Mom.SumW; ValSumW=Mom.ValSumW; Vals=Mom.Vals;
196  Mn=Mom.Mn; Mx=Mom.Mx;
197  Mean=Mom.Mean; Vari=Mom.Vari; SDev=Mom.SDev; SErr=Mom.SErr;
198  Median=Mom.Median; Quart1=Mom.Quart1; Quart3=Mom.Quart3; Mode=Mom.Mode;
200  return *this;}
TFlt SDev
Definition: xmath.h:138
TBool UsableP
Definition: xmath.h:135
TFlt Mx
Definition: xmath.h:137
TFlt Mode
Definition: xmath.h:140
TFlt Mn
Definition: xmath.h:137
#define Assert(Cond)
Definition: bd.h:251
TFlt Vari
Definition: xmath.h:138
TFlt SumW
Definition: xmath.h:133
TFlt ValSumW
Definition: xmath.h:133
TFlt Mean
Definition: xmath.h:138
TFlt Quart3
Definition: xmath.h:139
TFlt UnusableVal
Definition: xmath.h:136
TInt Vals
Definition: xmath.h:134
TFltPrV ValWgtV
Definition: xmath.h:132
TFlt SErr
Definition: xmath.h:138
TFlt Median
Definition: xmath.h:139
TBool DefP
Definition: xmath.h:131
TFltV PercentileV
Definition: xmath.h:142
TFltV DecileV
Definition: xmath.h:141
TFlt Quart1
Definition: xmath.h:139
bool TMom::operator== ( const TMom Mom) const
inline

Definition at line 201 of file xmath.h.

References Vals.

201  {
202  return Vals==Mom.Vals;}
TInt Vals
Definition: xmath.h:134
void TMom::Save ( TSOut SOut) const
inline

Definition at line 181 of file xmath.h.

181  {
182  DefP.Save(SOut);
183  ValWgtV.Save(SOut);
184  SumW.Save(SOut); ValSumW.Save(SOut); Vals.Save(SOut);
185  UsableP.Save(SOut); UnusableVal.Save(SOut);
186  Mn.Save(SOut); Mx.Save(SOut);
187  Mean.Save(SOut); Vari.Save(SOut); SDev.Save(SOut); SErr.Save(SOut);
188  Median.Save(SOut); Quart1.Save(SOut); Quart3.Save(SOut); Mode.Save(SOut);
189  DecileV.Save(SOut); PercentileV.Save(SOut);}
TFlt SDev
Definition: xmath.h:138
TBool UsableP
Definition: xmath.h:135
void Save(TSOut &SOut) const
Definition: dt.h:1150
TFlt Mx
Definition: xmath.h:137
TFlt Mode
Definition: xmath.h:140
void Save(TSOut &SOut) const
Definition: dt.h:992
void Save(TSOut &SOut) const
Definition: ds.h:954
TFlt Mn
Definition: xmath.h:137
TFlt Vari
Definition: xmath.h:138
TFlt SumW
Definition: xmath.h:133
TFlt ValSumW
Definition: xmath.h:133
TFlt Mean
Definition: xmath.h:138
TFlt Quart3
Definition: xmath.h:139
TFlt UnusableVal
Definition: xmath.h:136
TInt Vals
Definition: xmath.h:134
TFltPrV ValWgtV
Definition: xmath.h:132
TFlt SErr
Definition: xmath.h:138
TFlt Median
Definition: xmath.h:139
TBool DefP
Definition: xmath.h:131
TFltV PercentileV
Definition: xmath.h:142
TFltV DecileV
Definition: xmath.h:141
void Save(TSOut &SOut) const
Definition: dt.h:1399
TFlt Quart1
Definition: xmath.h:139

Friends And Related Function Documentation

friend class TPt< TMom >
friend

Definition at line 129 of file xmath.h.

Member Data Documentation

TCRef TMom::CRef
private

Definition at line 129 of file xmath.h.

TFltV TMom::DecileV
private

Definition at line 141 of file xmath.h.

Referenced by Def(), and operator=().

TBool TMom::DefP
private

Definition at line 131 of file xmath.h.

Referenced by Def(), and operator=().

TFlt TMom::Mean
private

Definition at line 138 of file xmath.h.

Referenced by Def(), and operator=().

TFlt TMom::Median
private

Definition at line 139 of file xmath.h.

Referenced by Def(), and operator=().

TFlt TMom::Mn
private

Definition at line 137 of file xmath.h.

Referenced by Def(), and operator=().

TFlt TMom::Mode
private

Definition at line 140 of file xmath.h.

Referenced by Def(), and operator=().

TFlt TMom::Mx
private

Definition at line 137 of file xmath.h.

Referenced by Def(), and operator=().

TFltV TMom::PercentileV
private

Definition at line 142 of file xmath.h.

Referenced by Def(), and operator=().

TFlt TMom::Quart1
private

Definition at line 139 of file xmath.h.

Referenced by Def(), and operator=().

TFlt TMom::Quart3
private

Definition at line 139 of file xmath.h.

Referenced by Def(), and operator=().

TFlt TMom::SDev
private

Definition at line 138 of file xmath.h.

Referenced by Def(), and operator=().

TFlt TMom::SErr
private

Definition at line 138 of file xmath.h.

Referenced by Def(), and operator=().

TFlt TMom::SumW
private

Definition at line 133 of file xmath.h.

Referenced by Def(), and operator=().

TFlt TMom::UnusableVal
private

Definition at line 136 of file xmath.h.

Referenced by operator=().

TBool TMom::UsableP
private

Definition at line 135 of file xmath.h.

Referenced by Def(), and operator=().

TInt TMom::Vals
private

Definition at line 134 of file xmath.h.

Referenced by GetValVStr(), operator<(), operator=(), and operator==().

TFlt TMom::ValSumW
private

Definition at line 133 of file xmath.h.

Referenced by Def(), and operator=().

TFltPrV TMom::ValWgtV
private

Definition at line 132 of file xmath.h.

Referenced by Def(), and operator=().

TFlt TMom::Vari
private

Definition at line 138 of file xmath.h.

Referenced by Def(), and operator=().


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