1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 4;
use Statistics::Descriptive;
{
my $stat = Statistics::Descriptive::Full->new();
$stat->add_data( 1, 10, 100 );
my $mode = $stat->mode();
# TEST
ok (!defined($mode),
"No mode for a flat distribution."
);
my $second_mode = $stat->mode();
# TEST
ok (!defined($second_mode),
"No mode after a second call."
);
}
{
my $stat = Statistics::Descriptive::Full->new();
$stat->add_data( 1, 5,5,5,10,19,19,30 );
my $mode = $stat->mode();
# TEST
is ($mode, 5,
"Mode is 5."
);
my $second_mode = $stat->mode();
# TEST
is ($second_mode, 5,
"Second call mode is 5."
);
}
|