DIRECTORY Rope, IO, ViewerClasses; Histograms: CEDAR DEFINITIONS = BEGIN ROPE: TYPE = Rope.ROPE; Histogram: TYPE = REF HistogramRep; HistogramRep: TYPE; NewHistogram: PROCEDURE --makes a 1D histogram [ factor: REAL _ 1, --x = I*factor + offset offset: REAL _ 0] RETURNS [Histogram]; Create2D: PROC [ iMin, iMax, jMin, jMax: INT, --bounds are inclusive on both ends iFactor, jFactor: REAL _ 1, --x = I*iFactor + iOffset iOffset, jOffset: REAL _ 0] --y = J*jFactor + jOffset RETURNS [Histogram]; Increment: PROCEDURE [h: Histogram, i: CARDINAL] = INLINE {Change[h, i, 1]}; Decrement: PROCEDURE [h: Histogram, i: CARDINAL] = INLINE {Change[h, i, -1]}; Change: PROCEDURE [h: Histogram, who: CARDINAL, howMuch: INTEGER]; IncrementTransformed: PROCEDURE [h: Histogram, xmin, xmax, x: REAL]; ChangeTransformed: PROC [h: Histogram, x: REAL, y: REAL _ 0, delta: INTEGER _ 1]; ClearAll: PROC [h: Histogram]; WriteTo: PROCEDURE [h: Histogram, to: IO.STREAM]; Show: PROCEDURE [ h: Histogram, viewerInit: ViewerClasses.ViewerRec _ [], format: ROPE _ NIL, --NIL means "%d" width: CARDINAL _ 0, --max number of chars produced when formatting iFreq: CARDINAL _ 0, --label every iFreq'th bin paint: BOOL _ TRUE] RETURNS [ViewerClasses.Viewer]; END. tHistograms.Mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Last Edited by: Spreitzer, May 24, 1985 3:38:32 pm PDT A Histogram is a simple 1D or 2D data collector. A 1D Histogram: is a sequence of counters addressed by an integer I in the range [0..IMax). IMax is automatically maintained to be about as big as needed. IMax cells are actually allocated, so keep IMax within reason. A 2D Histogram: is a 2D array of counters addressed by two integers , where their bounds are specified at creation time. Again, all counters are allocated, so keep bounds reasonable. Make a new one. All counters start at zero. increment counter number i. decrement counter number i: change counter number who Inverse Transform x by factor & offset, Round, and Increment Works for 1D or 2D Histograms. Sets all counters to 0. list non-zero counters display it in a viewer Κ”˜codešœ™Kšœ Οmœ1™