# 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
x = np.random.seed(123456)

# generate 50 random integers from 1 to 50 using random.randint() and make a
# frequency histogram
ranInt = np.random.randint(1,50,50)

plt.hist(ranInt,5)

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

plt.hist(newRan,5)

# generate 1000 floating point numbers uniformly distributed from 1 to 100 and make a
# frequency histogram
uniInt = np.random.uniform(1,100,1000)

plt.hist(uniInt, 5)

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

plt.hist(normInt,5)

# 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
denseInt = np.random.normal(50,5,1000)

plt.hist(denseInt, 5, density=True)

# import random and set seed
import random
random.seed(123456)

# Simulate drawing a single ball; each ball has a number from from 1 to 50
ball1 = random.randint(1,50)
print (ball1)

# Simulate drawing 100 balls and keep track of the number of balls
# that have a number less than 25
ballCount = 0
for i in range(100):
ballDrawn = random.randint(1,50)
if (ballDrawn < 25):
ballCount+=1
print (ballCount)

# Calculate discrete probability that you will draw a ball with a number <25 using 10,000
# simulations
drawTimes = 10000
ballNum = [(i+1) for i in range(50)]
ballCount = 0
for i in range(drawTimes):
if (random.choice(ballNum) < 25):
ballCount+=1
discreteProb = float(ballCount)/float(drawTimes)
print (f'The discrete probability is {discreteProb}')
#ball is either less than 25 or greater than or equal to 25
#24/50 chance the ball is less than 25 for a single event
theoProb = float(24/50)
print (f'The theorectical probability is {theoProb}')

# 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 ballTest():
drawBall = random.randint(1,50)
print (f'ball number: {drawBall}')
if (drawBall <25):
return True
else:
return False
print (ballTest())