import java.io.IOException; /** Histogram Test * @author Simon George * @version 1.0 31 Aug 2001 */ public class HistogramTest { public static void main (String[] args) throws IOException{ // Create an object of class Histogram // 20 bins covering a range on the x-axis from -3.0 to 3.0 Histogram myhist = new Histogram("my histogram", 20, -3.0, 3.0); // Fill the histogram with some numbers // this should give approx 50 in each bin with no under/over flows: for (int i=0; i<1000; i++){ double x = -3.0 + i * 6.0/1000.0; myhist.fill( x ); } // Dump the accumulated bin contents out to a file myhist.writeToFile("myhist.dat"); // Print a summary of the histogram to the console myhist.show(); // Get some info from the histogram and print it out System.out.println ("About this histogram:"); System.out.println (" entries " + myhist.entries()); System.out.println (" underflow " + myhist.underflow()); System.out.println (" overflow " + myhist.overflow()); System.out.println (" area " + myhist.area()); System.out.println (" mean " + myhist.mean()); } }