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. tFILE: Histograms.Mesa, from [Ivy]Random>Cedar>Histograms.DF Last Edited by: Spreitzer, September 24, 1984 10:44:43 am 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 Κ‡˜IcodešœF™FKšœ=™=K˜Kšœ0™0™KšœΙ™Ι—™K™­—K˜KšΟk œœ˜"K˜KšΠbx œœ œ˜Kš˜K˜Kšœœœ˜K˜Kšœ œœ˜#Kšœœ˜K˜šΟn œ œΟc˜.šœ˜Kšœœ ˜)Kšœœ˜—Kšœ ˜K˜Kšœ+™+—K˜šŸœ˜šœ˜Kšœœ #˜@Kšœœ ˜5Kšœœ ˜5—Kšœ ˜—K˜šŸ œ œœ˜2Kšœ˜K˜Kšœ™K˜—šŸ œ œœ˜2Kšœ˜K˜Kšœ™K˜—šŸœ œœ œ˜BKšœ™—K˜šŸœ œœ˜DK™<—K˜š Ÿœœœœ œ˜QK™—K˜šŸœœ˜K™—K˜šŸœ œœœ˜1Kšœ™—K˜šŸœ œ˜Kšœ ˜ Kšœ)˜)Kšœœœ ˜$Kšœœ .˜CKšœœ ˜/Kšœœœœ˜3K˜K™K˜—Kšœ˜K˜—…—ζ α