<jupyter_start><jupyter_text>Coin toss example P (H) = 1/4P (T) = 3/4 <NAME>:P(H,H) = 1/4 * 1/4P(H,T) = 1/4 * 3/4P(T,H) = 3/4 * 1/4 P(T,T) = 3/4 * 3/4Toss the coin twice to gurantee not biased.Would you roll a die six times if its biased?<jupyter_code>#1) A bank found that the average number of cars waiting during the noon hour at a drive-up
# window follows a Poisson distribution with a mean of 2 cars. 
# Make a chart of this distribution and answer these questions concerning the probability 
# of cars waiting at the drive-up window.
#A) What is the probability that no cars drive up in the noon hour?
lamda = 2 # Use the rate given
stats.poisson(lamda).pmf(0) 
# Random variable X:?
x = np.arange(0,10)
y = stats.poisson(lamda).pmf(x)
 
plt.bar(x,y)
plt.title('Poisson distribution with $\lambda = 2$')
plt.xlabel('Number of cars going through drive-thru at noon')
#B) What is the probability that 3 or more cars come through the drive through?
stats.poisson(lamda).sf(2).round(3)
#C) How likely is it that the drive through gets at least 1 car?
1- stats.poisson(lamda).pmf(0).round(3)
#2) Grades of State University graduates are normally distributed with a mean of 3.0 and 
# a standard deviation of .3. Calculate the following:
mean = 40
std = 15
#A) What grade point average is required to be in the top 5% of the graduating class?
gpa = stats.norm(mean, std)
gpa.pdf(5) # a 3.49 is required to be in the top 5%
#B) What GPA constitutes the bottom 15% of the class?
gpa.ppf(.15) # a 2.69 constitutes as the bottom 15% of the class
#C) An eccentric alumnus left scholarship money for students in the third decile from the bottom 
# of their class. Determine the range of the third decile. Would a student with a 2.8 grade point 
# average qualify for this scholarship?
# Use Decile (First dectile is 0-10 percentile)
g
#D) If I have a GPA of 3.5, what percentile am I in?
1- gpa.cdf(3.5) # if you have a 4.5 you will be in the top 4% of the class
#3) A marketing website has an average click-through rate of 2%. One day they observe 4326 visitors
# and 97 click-throughs. How likely is it that this many people or more click through?

lamda = .02 # Use the rate given
stats.poisson(lamda).cdf(.024) 
# you have a 98 percent chance of having this click through rate
x = np.arange(0,10)
y = stats.poisson(lamda).pmf(x)

plt.bar(x,y)
plt.title('Poisson distribution with $\lambda = .02$')
plt.xlabel('Number of cars going through drive-thru at noon')
#4) You are working on some statistics homework consisting of 100 questions where all of the answers
# are a probability rounded to the hundreths place. Looking to save time, you put down random 
# probabilities as the answer to each question.
#A) What is the probability that at least one of your first 60 answers is correct?
n_trials = 100
#Success is getting answer right
p_success = .01
# Random variable X: Number of questions answered correctly
stats.binom(n_trials, p_success).sf(60)
#5) The codeup staff tends to get upset when the student break area is not cleaned up. 
# Suppose that there's a 3% chance that any one student cleans the break area when they visit it, 
# and, on any given day, about 90% of the 3 active cohorts of 22 students visit the break area. 
# How likely is it that the break area gets cleaned up each day? How likely is it that it goes 
# two days without getting cleaned up? All week?
prob_clean = .03
days = 5
students = 59 
#6) You want to get lunch at La Panaderia, but notice that the line is usually very long at 
# lunchtime. After several weeks of careful observation, you notice that the average number of 
# people in line when your lunch break starts is normally distributed with a mean of 15 and 
# standard deviation of 3. If it takes 2 minutes for each person to order, and 10 minutes from 
# ordering to getting your food, what is the likelihood that you have at least 15 minutes left 
# to eat your food before you have to go back to class? Assume you have one hour for lunch, 
# and ignore travel time to and from La Panaderia.
Mean = 15 
std = 3
sim = 1_000_000
trials = 7
clean = 1
noclean = 0
simulation = np.random.choice([clean, noclean], size = (sim, trials), p = [0.03, 0.97])
prob = (simulation.sum(axis = 1) == 1).mean()
prob
#7)Connect to the employees database and find the average salary of current employees, along with 
# the standard deviation. For the following questions, calculate the answer based on modeling the 
# employees salaries with a normal distribution defined by the calculated mean and standard 
# deviation then compare this answer to the actual values present in the salaries dataset.
#A) What percent of employees earn less than 60,000?
#B) What percent of employees earn more than 95,000?
#C) What percent of employees earn between 65,000 and 80,000?
#D) What do the top 5% of employees make?<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07542129058775175, 'fraction_numerical': 0.0345252774352651, 'mean_word_length': 4.080375782881002, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '379187', 'license': 'MIT', 'n_tokens_mistral': 1589, 'n_tokens_neox': 1443, 'n_words': 776, 'path': 'probability_distributions.ipynb', 'repo_name': 'ljackson707/statistics-exercises', 'size': '4876'}