Randomize patterns ?
Posted: Sun Nov 13, 2016 7:44 pm
While playing with block and normal distributions I noticed that using the command
RANDOMIZE created some "interference
or aliasing" patterns. Look at the attached
picture: the first and third distribution use
Randomize in each loop creating some kind
of fabric "texture" or so..., while the second
and fourth distribution don't show this at all...
Why does the use of Randomize create this
patterns ?
Any hints to understand this are welcome
RANDOMIZE created some "interference
or aliasing" patterns. Look at the attached
picture: the first and third distribution use
Randomize in each loop creating some kind
of fabric "texture" or so..., while the second
and fourth distribution don't show this at all...
Why does the use of Randomize create this
patterns ?
Any hints to understand this are welcome
Code: Select all
REM Randomize "patterns" ?
REM sB5.6/iOS6.1/iPhone4/by Operator
REM
REM Program will plot 4 distrbutions
REM using 80000 points each
REM 1. Normal dist. val. & RANDOMIZE
REM 2. Normal dist. val. w/o RANDOMIZE
REM 3. Block dist. val. & RANDOMIZE
REM 4. Block dist. val. w/o RANDOMIZE
REM Why does the use of Randomize
REM create interference patters or
REM a not so random distribution ?
REM How to use Randomize at all ?
GRAPHICS
GRAPHICS CLEAR 1,1,1
FILL COLOR 0,0,0
FILL ALPHA 0.1
scr_w = 320
scr_w2 = scr_w/2
FOR i = 1 TO 80000
RANDOMIZE
y = 5 + RND(100)
x = rndGauss(scr_w2,60)
FILL CIRCLE x,y SIZE 0.5
NEXT i
BEEP
FOR i = 1 TO 80000
'RANDOMIZE
y = 110 + RND(100)
x = rndGauss(scr_w2,60)
FILL CIRCLE x,y SIZE 0.5
NEXT i
BEEP
FOR i = 1 TO 80000
RANDOMIZE
y = 215 + RND(100)
x = RND(scr_w)
FILL CIRCLE x,y SIZE 0.5
NEXT i
BEEP
FOR i = 1 TO 80000
'RANDOMIZE
y = 320 + RND(100)
x = RND(scr_w)
FILL CIRCLE x,y SIZE 0.5
NEXT i
BEEP
BEEP
END
DEF rndGauss(mean,stdDev)
'Standard NORMAL variate using
'Marsaglia polar method, code ported
'out of Wikipedia
WHILE q <= 0 OR q >= 1
u = 2 * RND(1) - 1
v = 2 * RND(1) - 1
q = u * u + v * v
END WHILE
p = SQR(-2 * LOG(q)/q)
'reset q value for next call
q = 0
RETURN mean + stdDev * p * u
END DEF