Harvard University Statistics Lab Homework Lab Homework #save your plots as an image file and upload separately (export > save as image) #save them as pn

Harvard University Statistics Lab Homework Lab Homework

#save your plots as an image file and upload separately (export > save as image)

Don't use plagiarized sources. Get Your Custom Essay on
Harvard University Statistics Lab Homework Lab Homework #save your plots as an image file and upload separately (export > save as image) #save them as pn
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT!
Order Essay

#save them as png with filename your_name_Lab3_plot

#Exercise 1

#The rain probability for the month of July in the city of Portland is 72%

#(a) What is the probability that it rains exactly 11 days

#(b) What is the probability that it rains 11 or fewer days?

#(c) What is the probability that it rains 27 or more days?

#(d) What is the probability that it rains more than 20 but less than 25 days?

#Exercise 2

#Suppose the winnings of gamblers at Las Vegas are normally distributed with

#mean $670 and standard deviation $38.

#(a) What is the probability of winning exactly $500?

#(b) What is the probability of winning $500 or less?

#(c) What is the probability of winning more than $800?

#(d) What is the probability of winning between $500 to $875?

#(e) Generate 10000 random numbers using rnorm function. Show how this

#distribution would look like. Add in the plot the mean, median and 20%

#trimmed mean (provide these values).

#Exercise 3

#In the previous problem, how much someone has to win to be in the top 5%?

——————————————————————-

LAB 3 EXAMPLE

#Lab 3-Contents

#1. Binomial Probability Distribution

#2. Normal Probability Distribution

#————————————–

# 1. Binomial Probability Distribution

#————————————–

# The binomial distribution is one of the most important distributions in statisitcs.

# Like it’s name suggests, bi-nomial, indicates that we are dealing with

# numbers that have only two possibilites (eg. Yes/No, Dead/Alive etc.)

#There are three main types of problems dealing with binomial probabilites:

#A) Finding the probability of EXACTLY x successes (Yes responses, deaths, boys)

#B) Finding the probability of < x successes OR > x successes

#C) Finding the probability of < x1 successes AND > x2 successes

# Let’s try one by semi-hand (we’ll have R do some computations)

# and then learn how to use R to solve these kinds of problems.

#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#

#EXAMPLE 1: Let’s say the probability for divorce is 45%. Out of 20 married couples,

#what is the probability of EXACTLY 5 of them getting divorced?

#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#

N=20 #n

K=5 # x

p=0.45

q=1-p

Nf=factorial(N) #n!

Kf=factorial(K) # x!

Nf/(Kf*factorial(N-K)) * p^K * (1-p)^(N-K)

#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#

#Binomial Probability (EXACT): dbinom(k, n, p)

#Where k: number of successes, n: number of trials,

#p: probability of success

#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#

#Let’s use the dbinom() command from R to answer this question

#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#

#EXERCISE 1-1: Use the dbinom() command to solve the problem in Example 1

#

#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#

dbinom(5, 20, 0.45)

# What if we wanted to know the probability of 5 OR fewer divorces?

# One strategey is to compute the probability for 5, 4, 3, 2, 1, 0 divorces and sum the probabilities

p5=dbinom(5, 20, 0.45)

p4=dbinom(4, 20, 0.45)

p3=dbinom(3, 20, 0.45)

p2=dbinom(2, 20, 0.45)

p1=dbinom(1, 20, 0.45)

p0=dbinom(0, 20, 0.45)

p0+p1+p2+p3+p4+p5

# This is a bit tedious, so let’s just use a new command called pbinom()

#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^#

#Binomial Probability (x <= k): pbinom(k, n, p) #Where k: <= number of successes, n: number of trials, #p: probability of success #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^# #*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*# #EXERCISE 1-2: Use the pbinom() command to solve the problem of computing the probability for # 5 or fewer divorces. # #*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*# pbinom(5, 20, 0.45) #??????????????????????????????????????????????????????????????# #Thought Question 1: How would the command change if the question # was worded as "Find the probabilty for less than 5 divorces"? pbinom(4, 20, 0.45) #??????????????????????????????????????????????????????????????# # The pbinom() command is useful, but only gives us probabilities for <= k # What if we wanted to know the probability of having >= k responses or > k?

# Because the probabilities have to add to exactly 1, we can use some simple math to figure this out

#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#

#EXAMPLE 2: The probability for divorce is 45%. Out of 20 married couples,

#what is the probability of >= 6 of them getting divorced?

#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#

# We know from above that the probability of <= 5 couples divorcing is 0.05533419 # If we think about it, then the probability of >=6 is just 1-0.05533419 = 0.9446658

# We could even use the pbinom() command with this by putting the 1 minus in front

1-pbinom(5, 20, 0.45)

#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#

#EXERCISE 1-3: Use the pbinom() command to solve the problem of computing the probability for

# > 7 divorces.

#

#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#

1-pbinom(7, 20, 0.45)

# Thus far we’ve covered how to answer 2 out of the 3 possible binomial probability probelms (A and B).

# Let’s think about how we could answer a question asking about a range of possible sucesses.

#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#

#EXAMPLE 3: The probability for divorce is 45%. Out of 20 married couples,

#what is the probability of >= 7 and <= 10 divorces? # 7=< p<=10 ? #*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*# # This problem has 2 parts. #1) Compute the probability for <=10 divorces pbinom(10, 20, 0.45) #2) Compute the probability for <= 6 divorces (YES, 6 not 7) pbinom(6, 20, 0.45) # The difference between these two probabilites is the probability between 7 and 10 pbinom(10, 20, 0.45) - pbinom(6, 20, 0.45) #Note: Probability will always be positive, so make sure you do the subtraction in the correct order #??????????????????????????????????????????????????????????????# #Thought Question 2: How would computing the probability # in example 3 change if the direction of the signs were reversed? # eg. <=7 & >=10

#p<=7 and p>=10

#??????????????????????????????????????????????????????????????#

pbinom(7, 20, 0.45)

1-pbinom(9, 20, 0.45)

#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#

#EXERCISE 1-4: Use the pbinom() command to solve the problem of computing the probability for

# > 4 AND <= 15 divorces. 4 1.96 on the standard normal distribution (mean=0, sd=1)

#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#

1-pnorm(1.96, 0, 1)

#We can generalize this to normal distributions that do not have a mean of 0 and SD of 1

#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#

#EXAMPLE 5: What is the probability of having a bmi < 25.2 if the mean bmi is 35 and SD = 5 # #*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*# #We can use pnorm() in this situation as well #1) pnorm(25.2, 35, 5) # 2) Z=(25.2-35)/5 pnorm(Z,0,1) #Notice that the answer we get: 0.0249979 is the same as the answer we got in Exercise 2-1. #??????????????????????????????????????????????????????????????# #Thought Question 3: Why do you think the answers are the same in # example 5 and exercise 2-1? #??????????????????????????????????????????????????????????????# (25.2-35)/5 #*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*# #EXERCISE 2-2: The average age for incoming college freshman is 18.2 years with SD=0.5. # What is the probability that a freshman will be between 18 and 19 years old? #*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*# pnorm(19, 18.2, .5) - pnorm(18, 18.2, .5) # We can also do these problems in reverse, where we are given the probability and have to find the values # at which that probability exists. When we do this, we are calculating the quantile of the normal distribution. #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^# #Normal Dist Probability (Quantile): qnorm(p, mean, sd) #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^# # Let's think about the problem we did in example 5 # We found the probability of a bmi < 25.2 when the mean of the distribution was 35, SD=5 # The probability was 0.0249979 # Let's see if qnorm() returns the correct result: qnorm(0.0249979, 35, 5) #*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*# #EXERCISE 2-3: The average age for incoming college freshman is 18.2 years with SD=0.5. # A researcher tells you that the 65% of the freshman were less than... # He can't seem to remember what age it was at that 65% of the freshman were less than, help him out. #*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*# qnorm(0.65, 18.2, .5) #????????????????????????????????????????????????????????????????????????????????????# #Thought Question 4: What if instead of knowing the age for the bottom 65% # we wanted to know how old a person needed to be in the top 10% of age in their class #?????????????????????????????????????????????????????????????????????????????????????????# qnorm(0.9, 18.2, .5)

Quick Homework Essays
Calculate your paper price
Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional and Experienced Academic Writers

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.