-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMonte Carlo(2).txt
More file actions
50 lines (40 loc) · 1.78 KB
/
Monte Carlo(2).txt
File metadata and controls
50 lines (40 loc) · 1.78 KB
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
43
44
45
46
47
48
49
50
import random
# Parameters
num_simulations = 5000
expected_return = 122.4
threshold = 117
min_threshold = 62.4
intermediate_min = 92.4
max_threshold = 182.4
intermediate_max = 152.4
# Counters for various thresholds
below_min_count = 0
below_threshold_count = 0
above_intermediate_min_count = 0
above_intermediate_max_count = 0
below_max_count = 0
# Perform simulations
for _ in range(num_simulations):
simulated_return = random.gauss(expected_return, 30)
if simulated_return <= min_threshold:
below_min_count += 1
if simulated_return >= intermediate_min:
above_intermediate_min_count += 1
if simulated_return <= threshold:
below_threshold_count += 1
if simulated_return >= intermediate_max:
above_intermediate_max_count += 1
if simulated_return <= max_threshold:
below_max_count += 1
# Calculate probabilities
probability_below_min = below_min_count / num_simulations * 100
probability_above_intermediate_min = above_intermediate_min_count / num_simulations * 100
probability_below_threshold = below_threshold_count / num_simulations * 100
probability_above_intermediate_max = above_intermediate_max_count / num_simulations * 100
probability_below_max = below_max_count / num_simulations * 100
# Print results
print(f"Probability of return below {min_threshold}: {probability_below_min:.2f}%")
print(f"Probability of return above {intermediate_min}: {probability_above_intermediate_min:.2f}%")
print(f"Probability of return below {threshold}: {100 - probability_below_threshold:.2f}%")
print(f"Probability of return above {intermediate_max}: {probability_above_intermediate_max:.2f}%")
print(f"Probability of return below {max_threshold}: {probability_below_max:.2f}%")