28
28
print "hrm, there's three elements in this mode: $mod\n"
29
29
if $mod->is_multimodal;
31
use Scalar::Util qw(blessed);
33
print "hrm, there's three elements in this mode: $mod\n"
34
if blessed($v2) and $v2->isa("Statistics::Basic::Vector");
36
31
Create a 20 point "moving" mode like so:
33
use Statistics::Basic qw(:all nofill);
38
35
my $sth = $dbh->prepare("select col1 from data where something");
37
my $mod = mode()->set_size($len);
43
39
$sth->execute or die $dbh->errstr;
44
40
$sth->bind_columns( my $val ) or die $dbh->errstr;
47
42
while( $sth->fetch ) {
49
43
$mod->insert( $val );
50
if( -- $count <= 0 ) {
44
if( defined( my $m = $mod->query ) ) {
48
print "Mode: $mod\n" if $mod->query_filled;
55
The full details are probably in the base module. If you have questions, just
57
The constructor takes a list of values, a single array ref, or a single
58
L<Statistics::Basic::Vector> as arguments. It returns a
59
L<Statistics::Basic::Mode> object.
61
Note: normally you'd use the L<mean()|Statistics::Basic/mode()> constructor,
62
rather than building these by hand using C<new()>.
64
=item B<is_multimodal()>
66
L<Statistics::Basic::Mode> objects sometimes return L<Statistics::Basic::Vector>
67
objects instead of numbers. When C<is_multimodal()> is true, the mode is a
70
=item B<_OVB::import()>
72
This module also inherits all the overloads and methods from
73
L<Statistics::Basic::_OneVectorBase>.
79
This object is overloaded. It tries to return an appropriate string for the
80
calculation or the value of the computation in numeric context.
82
In boolean context, this object is always true (even when empty).
84
If evaluated as a string, L<Statistics::Basic::Mode> will try to format a number
85
(like any other L<Statistics::Basic> object), but if the object
86
L</is_multimodal()>, it will instead return a L<Statistics::Basic::Vector> for
92
print "$x, $y\n"; # prints: [1, 2, 3], 2
94
If evaluated as a number, a L<Statistics::Basic::Mode> will raise an error when
95
the object L</is_multimodal()>.
64
103
Copyright 2009 Paul Miller -- Licensed under the LGPL
69
perl(1), L<Statistics::Basic>
107
perl(1), L<Statistics::Basic>, L<Statistics::Basic::_OneVectorBase>, L<Statistics::Basic::Vector>