-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ece647
commit 2aa8f6d
Showing
1 changed file
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,26 @@ | ||
# write your code here | ||
import matplotlib.pyplot as plt | ||
import random | ||
|
||
|
||
def flip_coin() -> dict: | ||
result = {i: 0.0 for i in range(11)} | ||
for _ in range(10000): | ||
flip_res = [random.choice([0, 1]) for _ in range(10)] | ||
head = sum(flip_res) | ||
result[head] += 1 | ||
|
||
for key in result: | ||
result[key] = round((result[key] / 10000) * 100, 2) | ||
|
||
return result | ||
|
||
|
||
def draw_gaussian_distribution_graph(result: dict) -> None: | ||
x_ = list(result.keys()) | ||
y_ = list(result.values()) | ||
|
||
plt.plot(x_, y_) | ||
plt.title("Gaussian Distribution") | ||
plt.xlabel("Heads count") | ||
plt.ylabel("Drop percentage") | ||
plt.show() |