in reply to build a distribution
You might find something like this useful. It plots line graphs of the sums at each interval, which might serve to help you select the best one for your purpose. The graph produced(*) using random data are pretty uninspiring, but serves its purpose.
Large; you'll need to scroll or scale
#! perl -slw use strict; use GD; use List::Util qw[ sum ]; sub rgb2n { unpack 'N', pack 'CCCC', 0, @_ } ## Gen some data my %counts; ++$counts{ int( rand( 5e3 ) + rand( 5e3 ) ) } for 1 .. 1e6; my @keys = sort{ $a <=> $b } keys %counts; my $gd = GD::Image->new( 10000, 2000, 1 ); for my $step ( reverse 1.. 10 ) { my $start = 0; my $last = 0; my $clr = 2**24 / $step; for( my $end = $start+$step-1; $end < $keys[ -1 ]; $end += $step ) + { my $sum = sum( @counts{ grep( defined $counts{ $_ }, $start..$ +end ) } ) // 0; # printf "%4d - %4d : %d\n", $start, $end, $sum; $gd->line( $start, 2000-$last, $end, 2000-$sum, $clr ) if $las +t; $start = $end + 1; $last = $sum; } } open IMG, '>:raw', 'junk14.png' or die $!; print IMG $gd->png; close IMG; ## Display the graph in the default image viewer system 'junk14.png';
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: build a distribution
by sflitman (Hermit) on Aug 07, 2010 at 22:31 UTC | |
by BrowserUk (Patriarch) on Aug 07, 2010 at 23:20 UTC |