Created
March 7, 2025 08:11
-
-
Save yeiichi/c64a2133b905b360dcae586102d942b1 to your computer and use it in GitHub Desktop.
Check N(mu, sigma) distribution visually.
This file contains hidden or 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
#!/usr/bin/env python3 | |
import matplotlib.pyplot as plt | |
from random import gauss | |
NUM_SAMPLES = 128 | |
def plot_gaussian_distribution(mu: float, sigma: float) -> None: | |
"""Check N(mu, sigma) distribution visually.""" | |
nums = [gauss(mu, sigma) for _ in range(NUM_SAMPLES)] | |
# Plot histogram | |
plt.hist(nums) | |
plt.show() | |
def get_user_input(prompt: str) -> float: | |
return float(input(f'\033[93m{prompt} >> \033[0m')) | |
if __name__ == '__main__': | |
m = get_user_input("mu?") | |
s = get_user_input("sigma?") | |
plot_gaussian_distribution(m, s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment