Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Challenge: Solving the Task Using Geometric Probability | Basic Concepts of Probability Theory
Probability Theory Basics

book
Challenge: Solving the Task Using Geometric Probability

Consider a square with a side length of 2 units centered at the origin (0, 0) in a Cartesian coordinate system.
What is the probability that a randomly chosen point within the square doesn't fall into a circle with a radius of 1 unit centered at the origin?
As we have a two-dimensional space of elementary events, we can calculate the ratio of the circle's area to the square's area. The ratio represents the probability of a point falling within the circle.

Tehtävä

Swipe to start coding

Calculate probability as the ratio between the blue area and the whole area of the square.

Ratkaisu

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}')
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 4
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}')
toggle bottom row
some-alt