Histograms with less than one bin are not useful (and tend to cause crashes!)
Histograms with very large numbers of bins are also of little use, and cause
other implementation headaches.
/* PSPP - a program for statistical analysis.
/* PSPP - a program for statistical analysis.
- Copyright (C) 2004, 2008, 2009, 2011 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2008, 2009, 2011, 2012 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
stat->accumulate (stat, NULL, c, 0, y);
}
stat->accumulate (stat, NULL, c, 0, y);
}
static void
acc (struct statistic *s, const struct ccase *cx UNUSED, double c, double cc UNUSED, double y)
{
static void
acc (struct statistic *s, const struct ccase *cx UNUSED, double c, double cc UNUSED, double y)
{
gsl_histogram_accumulate (hist->gsl_hist, y, c);
}
gsl_histogram_accumulate (hist->gsl_hist, y, c);
}
static void
destroy (struct statistic *s)
{
static void
destroy (struct statistic *s)
{
bins = (upper_limit - lower_limit) / 2.0;
bins = (upper_limit - lower_limit) / 2.0;
+ /* Force the number of bins to lie in a sensible range */
+ if (bins > 25)
+ bins = 25;
+
+ if (bins < 1)
+ bins = 1;
+
upper_limit *= half_bin_width;
lower_limit *= half_bin_width;
upper_limit *= half_bin_width;
lower_limit *= half_bin_width;