我知道,答案應該是我的座標的60%左右躺下內這一點,但我只是收到大約20%如何計算半徑爲35和65的兩個圓之間有多少個座標?
import random
import pylab
import numpy
pylab.close("all") #all import statements
x = [(random.randint(0,100)) for i in range(3000)] #creating list of x coordinates
y = [(random.randint(0,100)) for j in range(3000)] #creating list of y coordinates
array=zip(x,y) #creating an array by combining the x and y coordinates
counter = 0
for i, j in array:
if 35**2 <= (i**2+j**2) <= 65**2:
counter+= 1
print counter
誰能告訴我什麼即時做錯了什麼?
你怎麼知道,如果你使用的是隨機數? – squiguy 2013-04-09 22:56:00
過那麼大的一個樣本應該只是着眼於區域 – blablabla 2013-04-09 22:57:24