%description: Test auto range histogram strategy. %global: static void dumpBins(cHistogram& hist) { EV << hist.getName() << ": " << hist.getNumBins() << " bins: "; for (int i = 0; i <= hist.getNumBins(); ++i) EV << hist.getBinEdge(i) << " "; EV << std::endl; } static void collectAndDump(cRNG* rng, cHistogram& hist) { for (int i=0; i<200; i++) hist.collect(uniform(rng, 0, 1)); dumpBins(hist); } static cAutoRangeHistogramStrategy *makeStrategy(double lo, double hi, int numBins, cHistogram::Mode mode) { auto strategy = new cAutoRangeHistogramStrategy(numBins, mode); strategy->setRangeHint(lo, hi); return strategy; } %activity: cHistogram hist1("fixed", makeStrategy(-1.5, 1.5, 10, cHistogram::MODE_REALS)); cHistogram hist2("auto1", makeStrategy(NAN, 150, 10, cHistogram::MODE_REALS)); cHistogram hist3("auto2", makeStrategy(-1.5, NAN, 10, cHistogram::MODE_REALS)); cHistogram hist4("fixed_i", makeStrategy(-2, 2, 2, cHistogram::MODE_INTEGERS)); cHistogram hist5("auto1_i", makeStrategy(NAN, 200, 10, cHistogram::MODE_INTEGERS)); cHistogram hist6("auto2_i", makeStrategy(-2, NAN, 10, cHistogram::MODE_INTEGERS)); collectAndDump(getRNG(0), hist1); collectAndDump(getRNG(0), hist2); collectAndDump(getRNG(0), hist3); collectAndDump(getRNG(0), hist4); collectAndDump(getRNG(0), hist5); collectAndDump(getRNG(0), hist6); %contains: stdout fixed: 16 bins: -1.6 -1.4 -1.2 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 auto1: 15 bins: 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 auto2: 13 bins: -1.6 -1.4 -1.2 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1 fixed_i: 2 bins: -2 0 2 auto1_i: 10 bins: 0 20 40 60 80 100 120 140 160 180 200 auto2_i: 10 bins: -2 -1 0 1 2 3 4 5 6 7 8