in reply to Help with Histograms

Given that the input is a sequence of random numbers, you could synthesize your desired arrangement of bins directly with no loss of information:

use feature ":5.14"; use warnings FATAL => qw(all); use strict; use Data::Dump qw(dump pp); sub bins($$$$)# Fill some bins {my ($start, $count, $width, $samples) = @_; # Start bin, number of b +ins, bin width, number of samples my $bins; $bins->{$start+$width * int(rand $count)}++ for 1..$samples; $bins } pp(bins(-2, 3, 2, 8));

Produces:

{ "-2" => 4, "0" => 1, "2" => 3 }