in reply to Re^2: optimize percentile counting in hash
in thread optimize percentile counting in hash
use strict; use warnings; my @data = get_data(); # or however you get them my %count; foreach my $datum (@data) { ++$count{$datum}; } my %percentile; my $total = 0; foreach my $datum (sort { $a <=> $b } keys %count) { $total += $count{$datum}; $percentile{$datum} = $total / @data; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: optimize percentile counting in hash
by Anonymous Monk on Mar 21, 2008 at 02:27 UTC | |
by ikegami (Patriarch) on Mar 21, 2008 at 02:40 UTC |