+
+gsl_histogram *
+histogram_create(double bins, double x_min, double x_max)
+{
+ int n;
+ double bin_width ;
+ double bin_width_2 ;
+ double upper_limit, lower_limit;
+
+ gsl_histogram *hist = gsl_histogram_alloc(bins);
+
+
+ bin_width = chart_rounded_tick((x_max - x_min)/ bins);
+ bin_width_2 = bin_width / 2.0;
+
+ n = ceil( x_max / (bin_width_2) ) ;
+ if ( ! (n % 2 ) ) n++;
+ upper_limit = n * bin_width_2;
+
+ n = floor( x_min / (bin_width_2) ) ;
+ if ( ! (n % 2 ) ) n--;
+ lower_limit = n * bin_width_2;
+
+ gsl_histogram_set_ranges_uniform(hist, lower_limit, upper_limit);
+
+
+ return hist;
+}
+