Profile


Name
Randomeer
ID
101667
Shared with
Public
Parent
None
Children
None
Created on
December 09, 2015 at 06:40 AM UTC
Updated on
December 09, 2015 at 06:40 AM UTC
Description

Randomeer generates random ones and zeroes. The scriptlog from this recipe can be used as input to the standalone Lua script LuaRandom2 to generate a bitmap in PNG format.

Best for


Code


--[[ Randomeer This script generates a random 512x512 black and white bitmap, as 512 lines of 512 random ones and zeroes. The scriptlog output from this recipe can be input to the standalone script LuaRandom2.lua to convert the bitmap to png format. The goal is to visually assess the quality of the random number generator. See https://www.random.org/analysis/#visual for a detailed example This script is based on the PHP script found in http://boallen.com/random-numbers.html revision history ---------------- 2015/12/08 -- LociOiling -- new function ]]-- DEBUG = false -- Module Random -- Tvdl, 01-11-2012 Randomseed=os.time()%1000000 if DEBUG then print ( "seed = " .. Randomseed ) end function Seedrandom() math.randomseed(Randomseed) math.random(100) -- Because the first is not random end Seedrandom() rando = "" rands = {} for ii = 1, 512 do for jj = 1, 512 do rands [ #rands + 1 ] = math.random ( 0, 1 ) end end if DEBUG then print ( #rands .. " random numbers generated" ) end kk = 0 ll = 0 for ii = 1, 512 do rando = "" for jj = 1, 512 do kk = kk + 1 rando = rando .. rands [ kk ] end ll = ll + 1 print ( rando ) end if DEBUG then print ( ll .. " lines of 512 generated" ) end

Comments


LociOiling Lv 1

Randomeer generates 512 lines, each containing 512 random ones and zeroes.

The scriptlog from Randomeer can be input to the standalone Lua program LuaRandom2, which has been shared as a recipe. LuaRandom2 generates a PNG bitmap, which can then be compared to one generated by the standalone program LuaRandom.

The goal is to visually assess the quality of the random number generator. The output from this script can be compared to the output of the LuaRandom script.

See https://www.random.org/analysis/#visual for a detailed example