-
Notifications
You must be signed in to change notification settings - Fork 2
/
circle_shape_bombing_area.py
42 lines (35 loc) · 1.15 KB
/
circle_shape_bombing_area.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import numpy as np
import matplotlib.pyplot as plt
x = 0
y = 0
radius = 500
standard_deviation_x = 500
standard_deviation_y = 300
number_of_simulation = 1
number_of_strike_each_simulation = 40
for i in range(number_of_simulation):
hit = 0
miss = 0
point_x = []
point_y = []
for i in range(number_of_strike_each_simulation):
normal_random_num = np.random.randn()
current_x = standard_deviation_x*normal_random_num
normal_random_num = np.random.randn()
current_y = standard_deviation_y*normal_random_num
point_x.append(current_x)
point_y.append(current_y)
if np.sqrt(current_x**2 + current_y**2) <= radius:
hit += 1
else:
miss += 1
print("Number of hits =" ,hit)
print("Number of miss =", miss)
print("Number of Strikes on Target" , round(((hit/number_of_strike_each_simulation)*100) , 2) , "%")
theta = np.linspace(0, 2*np.pi, 100)
circle_x = radius*np.cos(theta)
circle_y = radius*np.sin(theta)
plt.plot(circle_x, circle_y, color="blue")
plt.scatter(point_x, point_y, color="red")
plt.axis('equal')
plt.show()