with this Code i got 60-65% ... but i need better Random
Code: Select all
Procedure Main
LOCAL i
LOCAL iMax := 1000
LOCAL nZahl
LOCAL nPosi
LOCAL aTreff := {}
SET ALTER TO _LOGFILE.TXT
SET ALTER ON
FOR i := 1 TO iMax
nZahl := RandomInt(1,iMax)
nPosi := ASCAN(aTreff,{|x| x[1] = nZahl } )
IF nPosi > 0
aTreff[nPosi,2] := aTreff[nPosi,2] +1
ELSE
AADD(aTreff,{nZahl,1} )
ENDIF
NEXT
? iMax := LEN(aTreff)
aTreff := ASort(aTreff,,, {|aX,aY| aX[2] < aY[2]} )
FOR i := 1 TO iMax
? aTreff[i,1],aTreff[i,2]
NEXT
SET ALTER OFF
SET ALTER TO
RETURN
Code: Select all
FUNCTION BaseRandom( nLimit )
STATIC snRandom := Nil
LOCAL nDecimals
LOCAL cLimit
IF snRandom == NIL
snRandom := SECONDS() / EXP( 1 )
ENDIF
snRandom := LOG( snRandom + SQRT( 2 ) ) * EXP( 3 )
snRandom := VAL( STR( snRandom - INT( snRandom ), 17, 15 ) )
cLimit := TRANSFORM( nLimit, "@N" )
nDecimals := AT( ".", cLimit )
IF nDecimals > 0
nDecimals := LEN( cLimit ) - nDecimals
ENDIF
RETURN ROUND( nLimit * snRandom, nDecimals )
// BaseRandom Function is example Random Function from Alaska, but
// it has a decided tendancy to avoid numbers near the edge of the range!