DIRECTORY IO, Rope, ViewerClasses; Histograms: CEDAR DEFINITIONS = { ROPE: TYPE = Rope.ROPE; Histogram: TYPE = REF HistogramRep; HistogramRep: TYPE; Create1D: PROC --makes a 1D histogram [ factor: REAL _ 1.0, --center x = (I+0.5)*factor + offset offset: REAL _ -0.5] RETURNS [Histogram]; Create2D: PROC [ iMin, iMax, jMin, jMax: INT, --bounds are inclusive on both ends iFactor, jFactor: REAL _ 1.0, --center x = (I+0.5)*iFactor + iOffset iOffset, jOffset: REAL _ 0.0] --center y = (J+0.5)*jFactor + jOffset RETURNS [Histogram]; Increment: PROC [h: Histogram, i: NAT] = INLINE {Change[h, i, 1]}; Decrement: PROC [h: Histogram, i: NAT] = INLINE {Change[h, i, -1]}; Change: PROC [h: Histogram, who: NAT, howMuch: INTEGER]; IncrementTransformed: PROC [h: Histogram, xmin, xmax, x: REAL]; ChangeTransformed: PROC [h: Histogram, x: REAL, y: REAL _ 0.0, delta: INTEGER _ 1]; ClearAll: PROC [h: Histogram]; Stats1D: PROC [h: Histogram] RETURNS [sum0: INT, sum1, sum2, avg, stdDev, xmin, xmax: REAL]; Stats2D: PROC [h: Histogram] RETURNS [sum0: INT, sumx, sumy: REAL]; WriteTo: PROC [h: Histogram, to: IO.STREAM]; Show: PROC [ h: Histogram, viewerInit: ViewerClasses.ViewerRec _ [], format: ROPE _ NIL, --NIL means "%d" width: NAT _ 0, --max number of chars produced when formatting updatePeriod: REAL _ -1.0, --If > 0, every updatePeriod seconds the viewer is repainted if it's out of date. If updatePeriod=0, the viewer is painted every time something changes. If updatePeriod<0, the viewer is never automatically repainted. paint: BOOL _ TRUE] RETURNS [ViewerClasses.Viewer]; Error: ERROR [msg: ROPE]; }. ΠHistograms.Mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Mike Spreitzer September 27, 1986 4:28:18 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. Works only for 1D histograms. Force x inside [xmin .. xmax], inverse transform by factor & offset, round, and Increment. Works for 1D or 2D Histograms. Sets all counters to 0. Consider the histogram a set of pairs, each saying that there are n counts in the bin centered on x. sum0 = S n sum1 = S n*x sum2 = S n*x2 avg = sum1/sum0 stdDev = SqRt[( S n*(x - avg)2 ) / ((Sn) - 1)] xmin = least x with non-zero n xmax = greatest x with non-zero n xmin>xmax W sum0=0 list non-zero counters display it in a viewer Κ&˜codešœ™Kšœ Οmœ1™Kšœžœ ‘Ϊ˜υKšœžœžœžœ˜3K˜K™—K˜Kš œžœžœ˜K˜Kšœ˜K˜—…—\R