from java.lang import System

t0= System.currentTimeMillis()

ds1= 2* randomn(0,100000) + 20
ds2= 1.2* randomn(0,10000) + 10

#print (  '1: ', System.currentTimeMillis() - t0 )

ds= append( ds1, ds2 )
s= sort( ds )
ds= ds[s]

#print (  '2: ', System.currentTimeMillis() - t0 )

plot( 0, histogram(ds,20) )

from org.virbo.dataset.DataSetUtil import kmeansCadence
km= kmeansCadence(ds,2)
#print (  '3: ', System.currentTimeMillis() - t0 )

plot( 1, km.property( QDataSet.DEPEND_0 ), km + randomn(0,ds.length())/10 )

#print (  '4: ', System.currentTimeMillis() - t0 )
writeToPng('test037_kmeans.png')