Bad Random Generators

Due to a nice idea by the forum user „rosenm“, EMT now shows the angle of a view in the user controlled mode of plot3d(). Here is an example where this is useful.

It is well known that random generators of the form

\(K_{n+1} = (aK_n+c) \mod m\)

can be bad. To demonstrate this, I used the following code.

>m=2^31; a=65539; c=5;
>k=iterate("mod(a*x+c,m)",1,3000);
>v=redim(k/m,1000,3)';
>plot3d(v[1],v[2],v[3],>points,style=".",angle=149°,>user):

The distribution itself does not look bad. but the dependence of three consecutive values shows a problem. Here is the plot.

test

 

The triplets concentrate on planes which are only visible at certain angles. How did I find the angle that worked? For this, it is very useful to see the actual parameters of view during the interaction with the plot.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.