---
title: HW04
subtitle: One Mean Hypotheses and Confidence Intervals
author: MATH--159
date: Fall 2020
output:
  html_document:
    highlight: tango
    theme: spacelab
    toc: yes  
---

```{r set chunk option, echo=F}
knitr::opts_chunk$set(echo = T,
                      warning=FALSE,
                      message=FALSE,
                      fig.height=4,
                      fig.align='center') #Chunk default settings
```

# Assignment Overview

This assignment is about the normal distribution, sample distribution, and how they are used to create confidence intervals and perform hypothesis tests.

## Instructions

- Read the instructions for each question. Put your answers where it says `Answer Here`. Don't put your answer in the bartacks.
- Turn in the assignment on Canvas. Don't worry about the due date. I'll allow late submissions.
  - See me in office hours or class if you're having trouble.


## Confident Interval Formula

The formual for creating a 95% confidence interval is \[ mean \pm MoE \] Remember that `MoE` is `2*SE` where `SE` stands for `Standard Error`. The standard error is the standard deviation divided by the square root of the sample size. \[ SE = \dfrac{\sigma}{\sqrt n}\]

You can calculate confidence interval by hand or by using a code block.

## Hypothesis Testing

Remember that there are four/five steps:

1. Formulate hypotheses. The hypotheses need to make a statement about the *parameter of interest* which is a parameter of the population about which you are making a guess.
2. Collect data. Usually the data is just given to you in this class.
3. Create confidence interval assuming the null hypothesis is true. See the confidence interval above.
4. Reach a decision. If the sample mean is in the confidence interval then you "fail to reject H0". If the sample mean is not in the confidence interval then you "reject H0."
5. Write you conclusion stating how you reached your decision and what you now believe.

# Don't touch this

Code block for questions.

```{r, include=FALSE}
quarter_mile_time <- mtcars$qsec
```

# Assignment

All questions are worth two points.

## Question 1

For this question you're going to use the `quarter_mile_time` data which is a variable that records the amount of time a car takes to finish a quarter mile race lap.

1. What is the sample average of `quarter_mile_time`?

```{r}
quarter_mile_time
```
HO 17.85 seconds is the average time to run one quarter mile

HA Te average to finish a quarter mile is anything other than 18.85

2. How many observations are in `quarter_mile_time`?

There are 32 observations

3. What is the standard deviation of `quarter_mile_time`?

```{r}
sd(quarter_mile_time)
```
The sd is about 1.78

4. Should you use standard deviation (normal distribution) or SE (sample distribution) of `quarter_mile_time`? Explain.

You should use the normal deviation because there are more than 30 participants

5. Create a 95% confidence interval to estimate the population mean of `quarter_mile_time`.

```{r}
mean<- 17.84
MOE<- 2*1.78/sqrt(32)

mean+MOE
mean-MOE
```
## Question 2

For this question you aren't going to use data. I will give you the sample mean, standard deviation, and number of observations.

1. Researchers at Ohlone are applying for a grant to fund educational reforms. To qualify for the grant, the average GPA for the school needs to be `2.5`. Formulate a pair of hypotheses that reflect the current beliefs.

HO The average GPA to qualify is 2.5
HA You need anything else to qualify

2. The researchers took a random sample of `200` students. The sample mean of GPA was `2.41` which was lower than the requirement of `2.5`. The standard deviation was `1.3`. Create a 95% confidence for the estimate of the population's mean GPA.

```{r}
mean<- 2.5
sd<- 1.3
MOE<- 2*sd/sqrt(200)

mean+MOE
mean-MOE
```
3. What is the outcome of the hypothesis test? Should the researchers believe that they will qualify for the grant or not?

They would not accept the HO as 2.5 because it is within the range of the new data
