MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / random_unit_square

Method random_unit_square

maths/pi_monte_carlo_estimation.py:17–21  ·  view source on GitHub ↗

Generates a point randomly drawn from the unit square [0, 1) x [0, 1).

(cls)

Source from the content-addressed store, hash-verified

15
16 @classmethod
17 def random_unit_square(cls):
18 """
19 Generates a point randomly drawn from the unit square [0, 1) x [0, 1).
20 """
21 return cls(x=random.random(), y=random.random())
22
23
24def estimate_pi(number_of_simulations: int) -> float:

Callers 1

estimate_piFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected