Виклик: Розв’язання задачі за допомогою геометричної ймовірності
Розгляньте квадрат зі стороною довжиною 2
одиниці, центрований у початку координат (0, 0)
у декартовій системі координат.
Яка ймовірність того, що випадково обрана точка всередині квадрата не потрапить у коло з радіусом 1
одиниця, центроване у початку координат?
Оскільки маємо двовимірний простір елементарних подій, можемо обчислити відношення площі кола до площі квадрата. Це відношення визначає ймовірність того, що точка потрапить у коло.
Завдання
Swipe to start coding
Обчисліть ймовірність як відношення площі синьої області до всієї площі квадрата.
Рішення
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import numpy as np
import matplotlib.pyplot as plt
# Define the radius of the circle and the side length of the square
radius = 1
side_length = 2
# Calculate the area of the circle and the square
circle_area = np.pi * radius**2
square_area = side_length**2
# Calculate the probability that point doesn't fall into a circle
probability = (square_area - circle_area) / square_area
# Print the solution
print(f'The probability that a randomly chosen point within the square do not fall into a circle is {probability:.4f}')
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 1. Розділ 4
single
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import numpy as np
import matplotlib.pyplot as plt
# Define the radius of the circle and the side length of the square
radius = 1
side_length = 2
# Calculate the area of the circle and the square
circle_area = np.pi * radius**2
square_area = side_length**2
# Calculate the probability that point doesn't fall into a circle
probability = (___ - ___) / square_area
# Print the solution
print(f'The probability that a randomly chosen point within the square do not fall into a circle is {probability:.4f}')
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат