ZBrushCentral

IRAND problem

@Leo
…and chiness are also some darky for me :smiley:
@Cameyo
If the range is too small, just add (past)artificialy 2 or more existant :wink:
So time to make a complet turn will be biggest than the Univers age :smiley:
Pilou

Hi all,
i have done some tests…

The first test is with the internal random generator (RAND).
It works quite well (see attached image). The sequence is visible, but it has big length.

The RVy routine (PRNG) is very good.
I have tried with (p=5087, k=2900) and (p=2027, k=1298) (see attached images too).
RVy1.jpg
I wish to known a method to find good p and k values :wink:

The Frenchy Pilou routine have some problems…because the range of floating number is very small within Zscript :frowning:
I have attached an image of result with this routine. The sequence is very short.
I had the same problem when i tried to write this function in zscript language:

/* uniform [0,1] random number generator
developed by Pierre Lecuyer based on a clever
and tested combination of two linear congruential
sequences
/
/

s1 and s2 are the seeds (nonnegative integers)
/
#include <math.h>
double uni()
{
static long s1 = 55555;
static long s2 = 99999;
static double factor = 1.0/2147483563.0;
register long k,z;
k= s1 /53668;
s1 =40014
(s1%53668)-k12211;
if (s1 < 0) s1 += 2147483563;
k=s2/52774;
s2=40692
(s2%52774)-k*3791;
if (s2 < 0) s2 += 2147483399;

/* z = abs(s1 ^ s2); */ z= (s1 - 2147483563) + s2; if (z &lt; 1) z += 2147483562; return(((double)(z))*factor);

}

In zscript 1.0/2147483563.0 got wrong value…

I have attached the ZPlace2 RevIb5 (with source ;)) for anyone who want to play.
Next i’ll write another Random Generator routine from Knuth book.

Thanks for viewing

cameyo

p.s. Unless mistakes all works fine :slight_smile:

Attachments

ZRAND.jpg

RVy2.jpg

Frenchy.jpg

…was a too simple walk :wink:
Some repetitive artefact seems arrive but…
it’s just a question of parameters
if you take the same
N= 0.2561 and euler =2.71828182864
and now N = (( N + euler ) ^ pi ) - int(( N + euler ) ^ pi )
You will obtain a drunk walk with a mysterious strange attraction towards the up screen and without repetition :smiley:
(tested to 50 000 000 iterations) not more because my poor basic is a little slow :rolleyes:
Pilou
Ps Interesting links about Random number!
Another one!

(RvY similar Pseudo Random Number Generator? )
Derrick HenryLehmer’s generator 1905-1991 (thx Poucet)
U = ( A * Un-1 ) Mod B
A and B prime numbers
Un-1 = germ (seed) <> 0
You will obtain
each and just one each number between 0 and B-1 :eek: :eek: :eek: magic :lol:

U = (16807 * Un-1 ) mod 2147483647
or more small
U = ( 16011 * Un-1 ) mod 65521

if the modulo function has some limits use that! (Pseudo Code)
Function Alea (U)
A = 16807 * U
B = 2147483647
Alea = A-(int(A/B)*B)
End Function

Zscript accept 2147483647 ?
Pilou
Ps Seems a joyous company :slight_smile: Not repetitive before (2 147 483 647 - 50 000 000) :lol:
Sans titre - 1.gif
Source (for yaBasic :cool: (Yet An Another Basic) :lol: Pc Windows - Text file)

Frenchy,
this works better !!!
Very good number generator.
I’m working on an’idea of using the decimal part of Pi Greek (3.1415…) to random walk.
I have the first 100.000 numbers and i’m trying to find a method to code it with zscript…
I have write a small delphi program to try the Knuth generator (see. vol.2 of his books) and i must admit it is one of the best.
I’ll post the image of Pi greek walking…later…maybe.

cameyo

Hi all,
here is the walking with Pi Greek…
Image1.jpg
The complete image is in attachment (half size and jpg :()…
I have upload an alpha image and the first 100000 decimals.

cameyo

p.s. plus the ZPlace2 Rev.Ib6

…for the storage of your 100 000 Pi number:)
Hi Cameyo
Just draw a little colored image 316*317 = 100172 pixols with 10 coded colors :slight_smile:
I suppose that Zscript is capable to read a color on the screen (key “C” for example :slight_smile:
And maybe these image can be curious also :rolleyes:
Pilou
Ps He he you are very speedy this day :smiley:
Pss What is the method to read your Alpha Image of the 100 000 decimal of Pi ? a direction = a decimal number ?

Well, to store the 100000 decimals i have used…zscript !!!
I have defined an array PiLIST(100000), then i have done a small Delphi program to translate 3.1415…into:
[VarSet,PiLIST(i),<current decimal>]
[VarInc(i)]
for each decimal.
The final zscript file (.txt) is 2.5 Mb !
To load the script my PC need 15 minutes, but i wonder how stable is ZBrush for this work.
Then i run the script…and discover the image.

Thanks my friend.

cameyo

Pss with my method of 10 Colors in Gif format for no deperdition you will obtain a file of 50 Kb so better than the file text of your 1000 000 pi Number :wink:

You right !!!
But to read a decimal from your color map i must use the function PixolPick and it is more,more slow than [VarSet, PiLIST(I), xxx] :wink:

Often the programs are a trade-off between speed and size.

Thanks again for your idea…maybe i’ll use it in another project.

cameyo

p.s your posts = my posts x 8 -----------> 8960 = 1120 x 8

How interpretate your Alpha 100 000 Image?
The drunk walk use 8 directions ?
in any case very similar image of the Lehmer generator :slight_smile: same familly of aspect!
Pilou
Ps You are 8 time more serious than me :smiley:

Frenchy,
the Alpha is the MRGBZgrab of the complete Pi Greek walk.
Yes, it use 8 direction (from 0 to 7) the decimals 8 and 9 are not considered (or, better, consideread as ‘pause walk’).
To test the Pi you must use one million of decimals at least…

ciao

cameyo

hahaha Cameyo!:wink:

how observant of you to notice the cameyo posts x8 = pilou / 8 = Cameyo.

You must rest my friend too many numbers on the brain!!:wink: