r35372 - in /branches/upstream/libstatistics-descriptive-perl/current: Changes MANIFEST META.yml examples/ examples/statistical-analysis.pl lib/Statistics/Descriptive.pm t/descr.t

ryan52-guest at users.alioth.debian.org ryan52-guest at users.alioth.debian.org
Thu May 14 00:35:43 UTC 2009


Author: ryan52-guest
Date: Thu May 14 00:35:38 2009
New Revision: 35372

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=35372
Log:
[svn-upgrade] Integrating new upstream version, libstatistics-descriptive-perl (2.9)

Added:
    branches/upstream/libstatistics-descriptive-perl/current/examples/
    branches/upstream/libstatistics-descriptive-perl/current/examples/statistical-analysis.pl
Modified:
    branches/upstream/libstatistics-descriptive-perl/current/Changes
    branches/upstream/libstatistics-descriptive-perl/current/MANIFEST
    branches/upstream/libstatistics-descriptive-perl/current/META.yml
    branches/upstream/libstatistics-descriptive-perl/current/lib/Statistics/Descriptive.pm
    branches/upstream/libstatistics-descriptive-perl/current/t/descr.t

Modified: branches/upstream/libstatistics-descriptive-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libstatistics-descriptive-perl/current/Changes?rev=35372&op=diff
==============================================================================
--- branches/upstream/libstatistics-descriptive-perl/current/Changes (original)
+++ branches/upstream/libstatistics-descriptive-perl/current/Changes Thu May 14 00:35:38 2009
@@ -1,4 +1,10 @@
 Revision history for Perl extension Statistics::Descriptive.
+
+    - Fixed bug https://rt.cpan.org/Public/Bug/Display.html?id=46026 :
+        - standard_deviation failing due to a variance that got evaluated
+        to 0 due to rounding errors.
+    - Kwalitee : added a LICENSE section to the POD.
+    - Kwalitee (CPANTS) : added an examples/ directory with a script.
 
 2.8   May 09, 2009
 

Modified: branches/upstream/libstatistics-descriptive-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libstatistics-descriptive-perl/current/MANIFEST?rev=35372&op=diff
==============================================================================
--- branches/upstream/libstatistics-descriptive-perl/current/MANIFEST (original)
+++ branches/upstream/libstatistics-descriptive-perl/current/MANIFEST Thu May 14 00:35:38 2009
@@ -1,5 +1,6 @@
 Build.PL
 Changes
+examples/statistical-analysis.pl
 inc/Test/Run/Builder.pm
 lib/Statistics/Descriptive.pm
 Makefile.PL

Modified: branches/upstream/libstatistics-descriptive-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libstatistics-descriptive-perl/current/META.yml?rev=35372&op=diff
==============================================================================
--- branches/upstream/libstatistics-descriptive-perl/current/META.yml (original)
+++ branches/upstream/libstatistics-descriptive-perl/current/META.yml Thu May 14 00:35:38 2009
@@ -1,6 +1,6 @@
 ---
 name: Statistics-Descriptive
-version: 2.8
+version: 2.9
 author:
   - 'Shlomi Fish <shlomif at iglu.org.il>'
 abstract: Module of basic descriptive statistical functions.
@@ -22,7 +22,7 @@
 provides:
   Statistics::Descriptive:
     file: lib/Statistics/Descriptive.pm
-    version: 2.8
+    version: 2.9
   Statistics::Descriptive::Full:
     file: lib/Statistics/Descriptive.pm
   Statistics::Descriptive::Sparse:

Added: branches/upstream/libstatistics-descriptive-perl/current/examples/statistical-analysis.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libstatistics-descriptive-perl/current/examples/statistical-analysis.pl?rev=35372&op=file
==============================================================================
--- branches/upstream/libstatistics-descriptive-perl/current/examples/statistical-analysis.pl (added)
+++ branches/upstream/libstatistics-descriptive-perl/current/examples/statistical-analysis.pl Thu May 14 00:35:38 2009
@@ -1,0 +1,71 @@
+#!/usr/bin/perl
+
+# This script analyses two distributions from tab-separated input 
+# and outputs some basic statistcs.
+#
+# It was used to analyse the distribution of the number of moves in
+# the solutions generated by http://fc-solve.berlios.de/ .
+
+use strict;
+use warnings;
+
+use Statistics::Descriptive;
+
+my $num_fields = 2;
+
+my @stats = 
+    (map 
+        { Statistics::Descriptive::Full->new(); } 
+        (1 .. $num_fields)
+    );
+
+while(my $line = <ARGV>)
+{
+    chomp($line);
+    my @vals = split(/\t/, $line);
+    foreach my $f (0 .. $num_fields-1)
+    {
+        $stats[$f]->add_data($vals[$f]);
+    }
+}
+
+foreach my $f (0 .. $num_fields-1)
+{
+    my $s = $stats[$f];
+    print "Field No. $f\n";
+    print "---------------------------\n";
+    print "Min: " , $s->min(), "\n";
+    print "Max: " , $s->max(), "\n";
+    print "Average: " , $s->mean(), "\n";
+    print "StdDev: " , $s->standard_deviation(), "\n";
+    print "Median: " , $s->median(), "\n";
+    print "\n";
+}
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (c) 2009 Shlomi Fish
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+=cut
+

Modified: branches/upstream/libstatistics-descriptive-perl/current/lib/Statistics/Descriptive.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libstatistics-descriptive-perl/current/lib/Statistics/Descriptive.pm?rev=35372&op=diff
==============================================================================
--- branches/upstream/libstatistics-descriptive-perl/current/lib/Statistics/Descriptive.pm (original)
+++ branches/upstream/libstatistics-descriptive-perl/current/lib/Statistics/Descriptive.pm Thu May 14 00:35:38 2009
@@ -10,7 +10,7 @@
 		  ##Perl5.  01-03 weren't bug free.
 use vars (qw($VERSION $Tolerance));
 
-$VERSION = '2.8';
+$VERSION = '2.9';
 
 $Tolerance = 0.0;
 
@@ -117,7 +117,20 @@
   my $variance = $self->{variance};
   if (!defined($variance)) {
     $variance = ($self->{sumsq} - $count * $self->{mean}**2);
+
+    # Sometimes due to rounding errors we get a number below 0.
+    # This makes sure this is handled as gracefully as possible.
+    #
+    # See:
+    #
+    # https://rt.cpan.org/Public/Bug/Display.html?id=46026
+    if ($variance < 0)
+    {
+        $variance = 0;
+    }
+
     $variance /= $count - $div;
+
     $self->{variance} = $variance;
   }
   return $variance;
@@ -857,6 +870,11 @@
 reserved.  This program is free software; you can redistribute it
 and/or modify it under the same terms as Perl itself.
 
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
 =head1 REVISION HISTORY
 
 =over 4

Modified: branches/upstream/libstatistics-descriptive-perl/current/t/descr.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libstatistics-descriptive-perl/current/t/descr.t?rev=35372&op=diff
==============================================================================
--- branches/upstream/libstatistics-descriptive-perl/current/t/descr.t (original)
+++ branches/upstream/libstatistics-descriptive-perl/current/t/descr.t Thu May 14 00:35:38 2009
@@ -3,8 +3,7 @@
 use strict;
 use warnings;
 
-# Should be 14.
-use Test::More tests => 14;
+use Test::More tests => 16;
 
 use Benchmark;
 use Statistics::Descriptive;
@@ -61,6 +60,20 @@
 
     ok($success, $blurb);
 }
+
+sub is_between
+{
+    local $Test::Builder::Level = $Test::Builder::Level + 1;
+    
+    my ($have, $want_bottom, $want_top, $blurb) = @_;
+
+    ok (
+        (($have >= $want_bottom) &&
+        ($want_top >= $have)),
+        $blurb
+    );
+}
+
 # print "1..14\n";
 
 # test #1
@@ -239,3 +252,24 @@
 ok ($t[1] < $t[0],
     "trimmed_mean caching works",
 );
+
+{
+    my $stat = Statistics::Descriptive::Full->new();
+
+    $stat->add_data((0.001) x 6);
+
+    # TEST
+    is_between ($stat->variance(),
+        0,
+        0.00001,
+        "Workaround to avoid rounding errors that yield negative variance."
+    );
+
+    # TEST
+    is_between ($stat->standard_deviation(),
+        0,
+        0.00001,
+        "Workaround to avoid rounding errors that yield negative std-dev."
+    );
+}
+




More information about the Pkg-perl-cvs-commits mailing list