pspp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug #47139] EXAMINE plot histogram does wrong binning


From: John Darrington
Subject: Re: [bug #47139] EXAMINE plot histogram does wrong binning
Date: Mon, 15 Feb 2016 21:15:38 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Mon, Feb 15, 2016 at 06:52:03PM +0000, Friedrich Beckmann wrote:
     
     I fixed this problem with commit
     
     
http://git.savannah.gnu.org/cgit/pspp.git/commit/?id=ca4012bcf0f8790ceb8539b55bbc296d0802d5d7
     
     Now all cases are considered in the histogram. 

I don't think this is the right fix.

There will still be a problem in the case where max == adjusted_max

For example:

data list list /x *.
begin data.
1
2
3
4
5
6
7
8
9
10
end data.

examine x
        /plot = histogram.

The last bin has 3 items and thus distorts the histogram.


I was going to suggest a fix like this:

From 8e381363c45e8be168d742bcdf2debf17c690ba4 Mon Sep 17 00:00:00 2001
From: John Darrington <address@hidden>
Date: Mon, 15 Feb 2016 21:05:09 +0100
Subject: [PATCH] Fix for missing bin

---
 src/math/histogram.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/math/histogram.c b/src/math/histogram.c
index 9158590..c69006b 100644
--- a/src/math/histogram.c
+++ b/src/math/histogram.c
@@ -143,6 +143,12 @@ histogram_create (double bin_width_in, double min, double 
max)
 
   h = xmalloc (sizeof *h);
 
+  if (adjusted_max >= max)
+    {
+      adjusted_max += (adjusted_max - adjusted_min) / bins;
+      bins++;
+    }
+
   h->gsl_hist = gsl_histogram_alloc (bins);
 
   gsl_histogram_set_ranges_uniform (h->gsl_hist, adjusted_min, adjusted_max);
-- 





-- 
Avoid eavesdropping.  Send strong encryted email.
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://sks-keyservers.net or any PGP keyserver for public key.

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]