Code: Select all
#ifdef __FB_UNIX__
Const TEST_COMMAND = "ls *"
#else
Const TEST_COMMAND = "dir *.*"
#endif
Open Pipe TEST_COMMAND For Input As #1
Dim As String ln
Do Until EOF(1)
Line Input #1, ln
Print ln
Loop
Close #1
sleep
Code: Select all
#ifdef __FB_UNIX__
Const TEST_COMMAND = "ls *"
#else
Const TEST_COMMAND = "dir *.*"
#endif
Open Pipe TEST_COMMAND For Input As #1
Dim As String ln
Do Until EOF(1)
Line Input #1, ln
Print ln
Loop
Close #1
sleep
Code: Select all
function pipeoutALL(cmd As String) as string
dim as string File = "__testcode__"
var e =Shell (cmd+" "+" >>"+file+" 2>&1")
Var f=Freefile,txt="",L=0
Open file For Binary As #f
L=Lof(f)
If L>0 Then
txt = String(L,0)
Get #f, , txt
End If
Close #f
Kill File
return txt
End function
Function pipeout( s As String) As String
Var f=Freefile
Open Pipe s For binary As #f
s=""
put #f,,s
close #f
Return s
End Function
print pipeout("g++")
print pipeoutALL("g++")
sleep
Code: Select all
"myrandoms.cpp"
This was run on Linux using Practrand v 0.94
The test took 63 minutes
rng=RNG_stdin32, seed=unknown
length= 256 gigabytes (2^38 bytes), time= 938 seconds
no anomalies in 249 test result(s)
rng=RNG_stdin32, seed=unknown
length= 512 gigabytes (2^39 bytes), time= 1884 seconds
no anomalies in 257 test result(s)
rng=RNG_stdin32, seed=unknown
length= 1 terabyte (2^40 bytes), time= 3789 seconds
no anomalies in 265 test result(s)
"my64.bas"
This was run on Linux. The test took 2hrs 56 minutes
rng=RNG_stdin64, seed=unknown
length= 256 gigabytes (2^38 bytes), time= 2318 seconds
no anomalies in 324 test result(s)
rng=RNG_stdin64, seed=unknown
length= 512 gigabytes (2^39 bytes), time= 4616 seconds
no anomalies in 335 test result(s)
rng=RNG_stdin64, seed=unknown
length= 1 terabyte (2^40 bytes), time= 9220 seconds
no anomalies in 346 test result(s)
"my64.bas"
This was run on Windows. The Test took 6 hours
rng=RNG_stdin64, seed=unknown
length= 256 gigabytes (2^38 bytes), time= 5336 seconds
no anomalies in 284 test result(s)
rng=RNG_stdin64, seed=unknown
length= 512 gigabytes (2^39 bytes), time= 10816 seconds
no anomalies in 295 test result(s)
rng=RNG_stdin64, seed=unknown
length= 1 terabyte (2^40 bytes), time= 21578 seconds
no anomalies in 304 test result(s)
Code: Select all
#cmdline "-gen gcc -O 2"
namespace rand64
dim as ulongint a,b,c,d,e
const max=18446744073709551615ull
function rndU as ulongint
e = a - ((b shl 7) or (b shr (57)))
a = b xor ((c shl 13) or (c shr (51)))
b = c + ((d shl 37) or (d shr (27)))
c = d + e
d = e + a
return d
end function
sub autoinit() constructor
var n=timer
a=n:b=n:c=n:d=n
for m as long=n to n+2
a+=m
rndU()
next
print "automatic warm up done"
end sub
sub init(n as long)
rand64.a=n:rand64.b=n:rand64.c=n:rand64.d=n
for m as long=n to n+2
rand64.a+=m
rand64.rndU()
next
end sub
#define rndf rand64.rndU/rand64.max
#define rangeI(f,l) clngint((rand64.rndU() mod (((l)-(f))+(1))) + (f))
#define rangeF(f,l) Rndf * ((l) - (f)) + (f)
end namespace
type range
as double _max,_min,sd
as long _maxi,_mini
end type
function mean(a() as double,R as range) as double
R=type(-1e10,1e10,0,0,0)
dim as long lb=lbound(a),ub=ubound(a)
dim as double acc,m
for n as long=lb to ub
acc+=a(n)
if R._max<a(n) then R._max=a(n):R._maxi=n
if R._min>a(n) then R._min=a(n):R._mini=n
next
m=acc/(ub-lb+1)
acc=0
for n as long=lb to ub
acc+=(a(n)-m)*(a(n)-m)
next
R.sd =sqr(acc/(ub-lb))
return m
end function
function chisquared(a() as double,R as range,byref m as double) as double
m=mean(a(),R)
dim as double acc
for n as long=lbound(a) to ubound(a)
acc+=(a(n)-m)*(a(n)-m)/m
next
return acc
end function
dim as ulong lim=50000000
rand64.init(timer)
var low=0
var high=10
Dim As Double a(low to high)
For n As ulong=1 To lim
Dim As long u= rangei(low,high)
a(u)+=1
Next
print "ok"
dim as range R
dim as double m
var c=chisquared(a(),R,m)
print "Mean ";m;" Standard dev. ";R.sd;" Min ";R._min;" Max ";R._max;" difference ";R._max-R._min
print "chi squared distance ";c
print "Done"
sleep
I don't think we can "really measure true randomness" and it probably does not exist in our world.dodicat wrote:So you cannot really measure true randomness I reckon, if it exists in the first place.
Code: Select all
' for now I will try this example with the shell command and writing a file to the hard drive.
' this code is not working only an Example
' this would write a 1k file to the hard drive
' For i = 1 1o 1024
' x = rnd(rnd * 256)
' abyte = x 'converts ushort to a ubyte
' put #1,,abyte ' this would be binary data
' next
' then i use the shell command
' shell "your path to tally.exe" 'This would save time analyzing files