in reply to Perl hit counter for multiple ranges, optimization or options in other languages?
You're asking for a frequency distribution. Statistics::Descriptive makes very quick work of this (and much more):
use Statistics::Descriptive; my @ranges = (19, 29, 39); # 1..19, 20..29, 30..39 my $stat = Statistics::Descriptive::Full->new; $stat->add_data( 12, 14, 15, 20, 21 ); my %dist = $stat->frequency_distribution(\@ranges); printf " %5d: %4d\n", $_, $dist{$_} for @ranges;
Output:
19: 3 29: 2 39: 0
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl hit counter for multiple ranges, optimization or options in other languages?
by SaktiMonk (Initiate) on Aug 07, 2013 at 22:43 UTC | |
by locked_user sundialsvc4 (Abbot) on Aug 07, 2013 at 23:48 UTC | |
|
Re^2: Perl hit counter for multiple ranges, optimization or options in other languages?
by SaktiMonk (Initiate) on Aug 10, 2013 at 01:25 UTC |