Array-Make-Histogram was using (n-1) bins when asked for n-bin
authorPanayotis Skordos <edu/mit/csail/zurich/pas>
Fri, 20 Nov 1987 16:39:02 +0000 (16:39 +0000)
committerPanayotis Skordos <edu/mit/csail/zurich/pas>
Fri, 20 Nov 1987 16:39:02 +0000 (16:39 +0000)
histogram. Fixed.

v7/src/microcode/array.c

index 9afe1af77683cfd032688351d040583652a4fa40..e2bb378ea59ba5c97d0e5372ea1c5aefd786c93d 100644 (file)
@@ -30,7 +30,7 @@ Technology nor of any adaptation thereof in any advertising,
 promotional, or sales literature without prior written consent from
 MIT in each case. */
 
-/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/array.c,v 9.23 1987/10/24 09:42:18 pas Rel $ */
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/array.c,v 9.24 1987/11/20 16:39:02 pas Exp $ */
 
 /* CONTAINS:                                                         */
 /* Scheme_Array constructors, and selectors                          */
@@ -598,11 +598,11 @@ void C_Array_Make_Histogram(Array, Length, Histogram, npoints)
   long i, nmin,nmax, index;
   C_Array_Find_Min_Max(Array, Length, &nmin,&nmax);
   Min=Array[nmin]; Max=Array[nmax];
-  Find_Offset_Scale_For_Linear_Map(Min,Max, 0.0, ((REAL) (npoints-1)), &Offset, &Scale);
-  for (i=0;i<npoints;i++) {
-    Histogram[i] = 0.0; }
+  Find_Offset_Scale_For_Linear_Map(Min,Max, 0.0, ((REAL) npoints), &Offset, &Scale);
+  for (i=0;i<npoints;i++) Histogram[i] = 0.0;
   for (i=0;i<Length;i++) {
     index = (long) (floor((double) ((Scale*Array[i]) + Offset)));
+    /* Everything from 0 to 1 maps to bin 0, and so on */
     Histogram[index] += 1.0; }
 }