/*------------------------------------------------------------- Copyright (C) 2000 Sebastian Will. All Rights Reserved. Permission to use, copy, modify, and distribute this software and its documentation for NON-COMMERCIAL purposes and without fee is hereby granted provided that this copyright notice appears in all copies. THE AUTHOR AND PUBLISHER MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE AUTHORS AND PUBLISHER SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -------------------------------------------------------------*/ /*-------------------------- hist.c Written by S. Will. Constructs histogram file. One has to adapt MIN, MAX to expected minimum and maximum values in input file, as well as CLASSES (number of bins for histogram). Best to use gnuplot with output file, as in gnuplot plot "output" with boxes Use help file in gnuplot for further information. Gnuplot allows one to save the graph as ps,latex, and other formats. --------------------------------*/ /* compute the histogram to given input data */ #include #include /* range of input values */ #define MIN 0.0 #define MAX 2.0 /* number of classes for histogram */ #define CLASSES 200 int over_count; int under_count; int count[CLASSES]; int main() { int i; double x; int index; int total=0; /* init */ for (i=0; i=CLASSES) over_count++; else count[index]++; total++; } /* output */ if (under_count) fprintf(stderr,"underflow %f%%\n",100*under_count/(double)total); if (over_count) fprintf(stderr,"overflow %f%%\n",100*over_count/(double)total); for (i=0; i