59 #include <gsl/gsl_histogram.h>
72 printf (
"Usage: gsl-histogram xmin xmax n\n"
73 "Computes a histogram of the data "
74 "on stdin using n bins from xmin "
87 gsl_histogram * h = gsl_histogram_alloc (n);
88 gsl_histogram_set_ranges_uniform (h, a, b);
90 while (fscanf (stdin,
"%lg", &x) == 1)
92 gsl_histogram_increment (h, x);
95 gsl_histogram_fprintf (stdout, h,
"%g",
"%g");
96 gsl_histogram_free (h);
114 f[i] = h->ydata[i] - h->gdata[i];
115 total += h->gdata[i];
138 st_report(
"Histogram moment: %11.6f", total);
139 st_report(
"Histogram Percent: %11.6f", rms / total * 100.0);
150 gsl_histogram *histo;
171 if(min > 0.0 || max < 0.0)
173 st_fail(
"Please remove a DC offset first");
177 histo = gsl_histogram_alloc(n);
178 gsl_histogram_set_ranges_uniform(histo, min, max);
182 gsl_histogram_increment(histo, (
double)
h0->
yplot1[i]);
190 sprintf(fname,
"histo.dat");
192 if((fp = fopen(fname,
"w") ) <= (FILE *)0)
194 st_fail(
"Unable to open %s", fname);
199 gsl_histogram_fprintf(fp, histo,
"%g",
"%g");
203 st_report(
"Histogram Written to %s", fname);
208 bzero((
char *)h,
sizeof(*h));
210 strcpy(h->
magic,
"HISTOGRAM");
217 h->
xdata[i] = histo->range[i];
218 h->
ydata[i] = histo->bin[i];
223 st_report(
"Histogram Max: %11.6f", gsl_histogram_max_val(histo));
224 st_report(
"Histogram Min: %11.6f", gsl_histogram_min_val(histo));
225 st_report(
"Histogram Mean: %11.6f", gsl_histogram_mean(histo));
226 st_report(
"Histogram Sigma: %11.6f", gsl_histogram_sigma(histo));
227 st_report(
"Histogram Sum: %11.6f", gsl_histogram_sum(histo));
232 int pgauss, h1gauss, h2gauss, ret;
234 double a[4], dyda[4], y;
236 pgauss = gsl_histogram_max_bin(histo);
238 h1gauss = pgauss - (n/8);
239 h2gauss = pgauss + (n/8);
251 a[3] = fabs(xd[h1gauss]-xd[h2gauss]);
253 st_report(
"Histogram Gauss Input: %11.6f %11.6f %11.6f", a[1], a[2], a[3]);
260 st_report(
"Histogram Gauss Results: %11.6f %11.6f %11.6f", a[1], a[2], a[3]);
264 fgauss(xd[i], &a[0], &y, &dyda[0]);
281 st_report(
"Sent Histogram to Xgraphics");
283 gsl_histogram_free(histo);
struct LP_IMAGE_INFO * h0
float ydata[MAX_HISTO_LENGTH]
int sock_write(struct SOCK *s, char *message, int l)
#define LAST_PLOT_SPEC_HISTO
struct PARSE_STACK * args
int printH_FlagHelp(char *cmd)
int computeRms(float *y, int n, float *rms)
struct HISTO_INFO last_histo
float gdata[MAX_HISTO_LENGTH]
int dummie_main(int argc, char **argv)
float xdata[MAX_HISTO_LENGTH]
int computeHistoRMS(struct HISTO_INFO *h)