4 namespace TSnapDetail {
8 const double EffPairs = Percentile * DistNbrsCdfV.
Last().Dat;
10 for (ValN = 0; ValN < DistNbrsCdfV.
Len(); ValN++) {
11 if (DistNbrsCdfV[ValN].Dat() > EffPairs) {
break; }
13 if (ValN >= DistNbrsCdfV.
Len())
return DistNbrsCdfV.
Last().Key;
14 if (ValN == 0)
return 1;
16 const double DeltaNbrs = DistNbrsCdfV[ValN].Dat - DistNbrsCdfV[ValN-1].Dat;
17 if (DeltaNbrs == 0)
return DistNbrsCdfV[ValN].Key;
18 return DistNbrsCdfV[ValN-1].Key + (EffPairs - DistNbrsCdfV[ValN-1].Dat)/DeltaNbrs;
23 for (
int i = 0; i < DistNbrsCdfV.
Len(); i++) {
24 KdV.
Add(
TIntFltKd(
int(DistNbrsCdfV[i].Val1()), DistNbrsCdfV[i].Val2));
42 double Paths=0, SumLen=0;
43 for (
int i = 0; i < DistNbrsPdfV.
Len(); i++) {
44 SumLen += DistNbrsPdfV[i].Key * DistNbrsPdfV[i].Dat;
45 Paths += DistNbrsPdfV[i].Dat;
51 double Paths=0, SumLen=0;
52 for (
int i = 0; i < DistNbrsPdfV.
Len(); i++) {
53 SumLen += DistNbrsPdfV[i].Val1 * DistNbrsPdfV[i].Val2;
54 Paths += DistNbrsPdfV[i].Val2;
TSizeTy Len() const
Returns the number of elements in the vector.
TKeyDat< TInt, TFlt > TIntFltKd
double CalcEffDiamPdf(const TIntFltKdV &DistNbrsPdfV, const double &Percentile)
Helper function for computing a given Percentile of a (unnormalized) probability distribution functio...
const TVal & Last() const
Returns a reference to the last element of the vector.
static void GetCdf(const TIntPrV &PdfV, TIntPrV &CdfV)
double CalcAvgDiamPdf(const TIntFltKdV &DistNbrsPdfV)
Helper function for computing the mean of a (unnormalized) probability distribution function...
double CalcEffDiam(const TIntFltKdV &DistNbrsCdfV, const double &Percentile)
Helper function for computing a given Percentile of a (unnormalized) cumulative distribution function...
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Vector is a sequence TVal objects representing an array that can change in size.