MCPcopy Create free account
hub / github.com/BirolLab/abyss / trimFraction

Method trimFraction

Common/Histogram.cpp:23–40  ·  view source on GitHub ↗

Trim off the bottom fraction/2 and top fraction/2 data points. * At least (1 - fraction) of the data will remain. */

Source from the content-addressed store, hash-verified

21 * At least (1 - fraction) of the data will remain.
22 */
23Histogram Histogram::trimFraction(double fraction) const
24{
25 double low_cutoff = fraction/2;
26 double high_cutoff = 1.0f - fraction/2;
27 size_type n = size();
28
29 double cumulative = 0;
30 Histogram newHist;
31 for (Histogram::Map::const_iterator it = m_map.begin();
32 it != m_map.end(); it++) {
33 double temp_total = cumulative + (double)it->second / n;
34 if (temp_total > low_cutoff && cumulative < high_cutoff)
35 newHist.insert(it->first, it->second);
36 cumulative = temp_total;
37 }
38
39 return newHist;
40}
41
42/** Bin these elements into n buckets. The number of buckets returned
43 * may be smaller than n.

Callers 3

mainFunction · 0.80
mainFunction · 0.80
printHistogramStatsFunction · 0.80

Calls 3

beginMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected