# import the library numpy as np
# import the library matplotlib.pyplt as plt
import numpy as np
import matplotlib.pyplot as plt

# set a seed for your calculations so that they are reproducible
seed = np.random.seed(12345)

# generate 50 random integers from 1 to 50 using random.randint() and make a
# frequency histogram
seed = np.random.randint (low = 1, high = 50, size = 50)
print(seed)

plt.hist(seed, bins = 5)
plt.show()

# generate 10000 random integers from 1 to 50 using random.randint() and make a
# frequency histogram
# compare with previous histogram
seed2 = np.random.randint(low = 1, high = 50, size = 10000)

plt.hist(seed2, bins = 5)
plt.show()

# generate 1000 floating point numbers uniformly distributed from 1 to 100 and make a
# frequency histogram
seed3 = np.random.uniform(low = 1, high = 50, size = 10000)

plt.hist(seed3, bins = 5)
plt.show()

# generate 1000 floating point numbers normally distributed about a mean of 50
# with a standard deviation of 5 and make a frequency histogram
#
i = np.random.normal(50,5, size = 1000)

plt.hist(i, bins = 5)
plt.show()

# generate 1000 floating point numbers normally distributed about a mean of 50
# with a standard deviation of 5 and make a density histogram; compare with frequency
# histogram
n = np.random.normal(50,5, size = 1000)

plt.hist(n, bins = 5, density=True)
plt.show()

# import random and set seed
import random
i = np.random.seed(12345)

# Simulate drawing a single ball; each ball has a number from from 1 to 50
ballsim = np.random.randint(low = 1, high = 50)

# Simulate drawing 100 balls and keep track of the number of balls
# that have a number less than 25
ballsim = np.random.randint(low = 1, high = 50, size = 50)
max = 25
min = 0
for i in ballsim:
if i < max:
min = min + 1
print(f"There are {min} balls under 25")

# Calculate discrete probability that you will draw a ball with a number <25 using 10,000
# simulations
ballsim = np.random.randint(low = 1, high = 50, size = 10000)
max=25
min=0
for i in ballsim:

# Now suppose you are playing a game where you draw a ball. You win if you get a number
# <25 and lose otherwise. Write a function which draws a single ball and returns True
# if the number is <25 and false if it is >= 25
# Test out your function
def ballsimFunc():
i = np.random.randint(low = 1, high = 50)
if i < 25:
print("True")
elif i >= 25:
print("False")
print(i)
ballsimFunc()