MCPcopy Create free account
hub / github.com/catboost/catboost / CalcSampleQuantile

Function CalcSampleQuantile

catboost/libs/helpers/quantile.cpp:105–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105double CalcSampleQuantile(
106 TConstArrayRef<float> sampleRef,
107 TConstArrayRef<float> weightsRef,
108 const double alpha
109) {
110 if (sampleRef.empty()) {
111 return 0.0;
112 }
113 if (alpha <= 0) {
114 return *MinElement(sampleRef.begin(), sampleRef.end());
115 }
116 Y_ASSERT(0 <= alpha && alpha <= 1);
117 TVector<float> defaultWeights;
118 if (weightsRef.empty()) {
119 defaultWeights.resize(sampleRef.size(), 1.0);
120 weightsRef = defaultWeights;
121 }
122 Y_ASSERT(sampleRef.size() == weightsRef.size());
123 return sampleRef.size() < 100
124 ? CalcSampleQuantileLinearSearch(sampleRef, weightsRef, alpha)
125 : CalcSampleQuantileBinarySearch(sampleRef, weightsRef, alpha);
126}

Callers 3

Y_UNIT_TESTFunction · 0.85

Calls 8

MinElementFunction · 0.85
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected