Clase 5 PDF
Clase 5 PDF
Clase 5 PDF
X = []
Y = []
r = 0.3
N = 100
M = np.zeros((N,N))
for k in range(1000):
x = random()
for m in range(1000):
y = random()
if (x-0.5)**2+(y-0.5)**2<=r**2:
X.append(x)
Y.append(y)
for i in range(N):
for j in range(N):
if M[i][j]==1:
break
else:
for x in X:
for y in Y:
if 1/5 + (0.3/N)*i < x and x <= 1/5 + (0.3/N)*(i+1):
if 1/5 + (0.3/N)*j < y and y <= 1/5 + (0.3/N)*(j+1):
M[i][j] = 1
elif 1/2 + (0.3/N)*i < x and x <= 1/2 + (0.3/N)*(i+1):
if 1/2 + (0.3/N)*j < y and y <= 1/2 + (0.3/N)*(j+1):
M[i][j] = 1
1
plt.imshow(M,cmap='hot')
plt.show