# 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
np.random.seed(12345)

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

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

# data is a lot more clustered and hard to interpret than last histogram

# generate 1000 floating point numbers uniformly distributed from 1 to 100 and make a
# frequency histogram
x = np.random.uniform(1000)
y = 1 + 99*x
print (y)
plt.hist((x,y))

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

# 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
x= np.random.normal(1000)
x = 50 + (5)*x
plt.hist(x, density = True)

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

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

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

# Calculate discrete probability that you will draw a ball with a number <25 using 10,000
# simulations
ball = random.randint(1,50)
n = 1000
sum_count = 0
for i in range (0,n) :
tracking = ball = random.randint(1,50)
if ( i < 25):
sum_count = count + 1
print (sum_count)
sum_count = [0 for i in range (0,10000)]
dis_prob = [(num)/n for num in sum_count]
print (dis_prob)

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