In [2]:
import numpy as np
import matplotlib.pyplot as plt

konstanty pro čistě multiplikativní generátor RANDU firmy IBM

In [4]:
a=65539
m=2147483648

semínko

In [6]:
i_seed=12345
In [7]:
ndata=100000
In [8]:
x = np.zeros(ndata, dtype=float) #deklarace pole x-souradnic
y = np.zeros(ndata, dtype=float) #deklarace pole y-souradnic
color=np.zeros([ndata,3],dtype=float) #deklarace pole barva RGB
In [9]:
i_old=i_seed
for i in range(0,ndata):
   i_next=(a*i_old) % m
   i_old=i_next
   x[i]=i_next/m
   i_next=(a*i_old) % m
   i_old=i_next
   y[i]=i_next/m
   i_next=(a*i_old) % m
   i_old=i_next
   color[i,0]=i_next/m
   i_next=(a*i_old) % m
   i_old=i_next
   color[i,1]=i_next/m
   i_next=(a*i_old) % m
   i_old=i_next
   color[i,2]=i_next/m
In [10]:
plt.scatter(x,y,c=color,s=1)
plt.xlim(0,1)
plt.ylim(0,1)
plt.show()
No description has been provided for this image
In [ ]: