/* NetRexx */ options replace format comments java crossref symbols nobinary import java.math.BigDecimal import java.math.MathContext -- prologue numeric digits 20 -- get input, set defaults parse arg dp mu sigma ec . if mu = '' | mu = '.' then mean = 1.0; else mean = mu if sigma = '' | sigma = '.' then stdDeviation = 0.5; else stdDeviation = sigma if dp = '' | dp = '.' then displayPrecision = 1; else displayPrecision = dp if ec = '' | ec = '.' then elements = 1000; else elements = ec -- set up RNG = Random() numberList = java.util.List numberList = ArrayList() -- generate list of random numbers loop for elements rn = mean + stdDeviation * RNG.nextGaussian() numberList.add(BigDecimal(rn, MathContext.DECIMAL128)) end -- report say "Mean: " mean say "Standard Deviation:" stdDeviation say "Precision: " displayPrecision say drawBellCurve(numberList, displayPrecision) return -- ----------------------------------------------------------------------------- method drawBellCurve(numberList = java.util.List, precision) static Collections.sort(numberList) val = BigDecimal lastN = '' nextN = '' loop val over numberList nextN = Rexx(val.toPlainString()).format(5, precision) select when lastN = '' then nop when lastN \= nextN then say lastN otherwise nop end say '*\-' lastN = nextN end val say lastN return