# Demonstrate another lost feature of AutoHistogram, where it identifies 
# peaks.  I don't think this was ever used in production, but it could be 
# useful.
reset()
setLayout(4)

n= 1000
dist=  randomn(12345,20*n)*.35 + 4.34
dist2= randomn(12345,30*n)*.45 + 6.23
dist3= randomn(12345,10*n)*.15 + 8.9

dist= append( dist,dist2)
dist= append( dist,dist3)

plot(0,dist)

from org.virbo.dsutil import AutoHistogram
ah= AutoHistogram()
ah.doit(dist)

hist= ah.getHistogram()
plot(1, hist,title='Histogram')

plot(2,ah.peakIds(hist),title='Peak ID'  )

pks= ah.peaks(hist)
plotx(3, pks, ones( pks.length() ), title='Peaks', renderType='scatter' )
#plot(3,'Peaks', ah.peaks(hist) )