File tree 3 files changed +6
-1
lines changed
3 files changed +6
-1
lines changed Original file line number Diff line number Diff line change
1
+ os : linux
2
+ dist : bionic
1
3
language : python
2
4
python : 3.8
3
5
cache : pip
Original file line number Diff line number Diff line change 321
321
* [ Newton Raphson] ( https://github.com/TheAlgorithms/Python/blob/master/maths/newton_raphson.py )
322
322
* [ Numerical Integration] ( https://github.com/TheAlgorithms/Python/blob/master/maths/numerical_integration.py )
323
323
* [ Perfect Square] ( https://github.com/TheAlgorithms/Python/blob/master/maths/perfect_square.py )
324
+ * [ Pi Monte Carlo Estimation] ( https://github.com/TheAlgorithms/Python/blob/master/maths/pi_monte_carlo_estimation.py )
324
325
* [ Polynomial Evaluation] ( https://github.com/TheAlgorithms/Python/blob/master/maths/polynomial_evaluation.py )
325
326
* [ Prime Check] ( https://github.com/TheAlgorithms/Python/blob/master/maths/prime_check.py )
326
327
* [ Prime Factors] ( https://github.com/TheAlgorithms/Python/blob/master/maths/prime_factors.py )
Original file line number Diff line number Diff line change @@ -18,7 +18,8 @@ def random_unit_square(cls):
18
18
"""
19
19
Generates a point randomly drawn from the unit square [0, 1) x [0, 1).
20
20
"""
21
- return cls (x = random .random (), y = random .random ())
21
+ return cls (x = random .random (), y = random .random ())
22
+
22
23
23
24
def estimate_pi (number_of_simulations : int ) -> float :
24
25
"""
@@ -56,6 +57,7 @@ def estimate_pi(number_of_simulations: int) -> float:
56
57
57
58
# doctest.testmod()
58
59
from math import pi
60
+
59
61
prompt = "Please enter the desired number of Monte Carlo simulations: "
60
62
my_pi = estimate_pi (int (input (prompt ).strip ()))
61
63
print (f"An estimate of PI is { my_pi } with an error of { abs (my_pi - pi )} " )
You can’t perform that action at this time.
0 commit comments