5th semester files
This commit is contained in:
Binary file not shown.
@ -0,0 +1,113 @@
|
||||
# Homework 2 - Aidan Sharpe
|
||||
## 1
|
||||
Consider two **disjoint** events V and W and suppose we know the probabilities $P(V)$ and $P(W)$. What is a simple expression for $P(V \cap W^c)$, using only the information given? You may obtain the answer by drawing a Venn diagram or listing intermediate equations.
|
||||
|
||||
$$P(W^c) = 1 - P(W)$$
|
||||
If $V$ and $W$ are disjoint, then $V$ and $W^c$ must be joint. For joint probabilities:
|
||||
$$P(A \cap B) = P(A)P(B)$$
|
||||
Combining the above:
|
||||
$$P(V \cap W^c) = P(V)[1-P(W)]$$
|
||||
|
||||
|
||||
## 2
|
||||
Consider a portion of an electric circuit that includes three independent components, each of which can either be open or closed. In order for current to flow from point A to point B, at least one of these components must be closed. Each component has a probability of 0.85 of functioning properly and closing when activated.
|
||||
|
||||
### a)
|
||||
What is the probability that the current will flow from point A to point B?
|
||||
|
||||
Let $R_1$ be the event that relay 1 works, $R_2$ be the event that relay 2 works, $R_3$ be the event that relay 3 works, and $C$ be the event that current flows.
|
||||
$$P(C) = P(R_1 \cup R_2 \cup R_3)$$
|
||||
$$P(C) = P(R_1) + P(R_2) + P(R_3) - P(R_1 \cap R_2) - P(R_1 \cap R_3) - P(R_2 \cap R_3) + P(R_1 \cap R_2 \cap R_3)$$
|
||||
$$P(R_1) = P(R_2) = P(R_3) = 0.85$$
|
||||
$$P(R_1 \cap R_2) = P(R_1 \cap R_3) = P(R_2 \cap R_3) = 0.722$$
|
||||
$$P(R_1 \cap R_2 \cap R_3) = 0.614$$
|
||||
|
||||
Plugging in yields:
|
||||
$$P(C) = 0.9966$$
|
||||
|
||||
### b)
|
||||
What is the probability that relay 2 functioned, given that the current flowed from point A
|
||||
to point B?
|
||||
$$P(R_2 | C) = \frac{P(C|R_2)P(R_2)}{P(C)}$$
|
||||
Since current will always flow if relay 2 works:
|
||||
$$P(C|R_2) = 1$$
|
||||
$$\therefore P(R_2 | C) = \frac{P(R_2)}{P(C)} = 0.853$$
|
||||
|
||||
## 3
|
||||
Selena uses one of her four cars to drive to work everyday. She drives one and only one car to work each day.
|
||||
$$P(C_1) = 0.4$$
|
||||
$$P(C_2) = 0.3$$
|
||||
$$P(C_3) = 0.15$$
|
||||
$$P(C_4) = 0.15$$
|
||||
|
||||
Let $X$ be the event that Selena will arrive to work on time. Depending on the car used, the probability of $X$ varies.
|
||||
$$P(X|C_1) = 0.85$$
|
||||
$$P(X|C_2) = 0.9$$
|
||||
$$P(X|C_3) = 0.8$$
|
||||
$$P(X|C_4) = 0.8$$
|
||||
|
||||
### a)
|
||||
Find $P(C_2 \cup C_3)$:
|
||||
|
||||
Since $C_2$ and $C_3$ are disjoint events:
|
||||
$$P(C_2 \cup C_3) = P(C_2) + P(C_3) = 0.45$$
|
||||
|
||||
### b)
|
||||
$$P(C_1|X) = \frac{P(X|C_1)P(C_1)}{P(X)}$$
|
||||
$$P(X) = P((X|C_1) \cup (X|C_2) \cup (X|C_3) \cup (X|C_4)) = 0.85$$
|
||||
$$P(C_1|X) = \frac{0.85 \times 0.4}{0.85} = 0.4$$
|
||||
|
||||
## 4
|
||||
Suppose you are given four copies of the novel *Burns: The Expertise of Achievement*, which has become a very popular read amongst America’s urban youth. The four copies are known to contain two defectives. Your job is to test the books one at a time until the two defective books are found. Once you locate the two defective copies, you will stop testing. Let $X$ denote the number of the test on which the second defective copy of the book is found. Find the probability distribution for $X$.
|
||||
$$P(X=2) = \frac{1}{6}$$
|
||||
$$P(X=3) = \frac{1}{3}$$
|
||||
$$P(X=4) = \frac{1}{2}$$
|
||||
|
||||
## 5
|
||||
The probability distribution of $X$, the number of imperfections per 10 meters of a synthetic fabric in continuous rolls of uniform width, is given by:
|
||||
|$x$|$f(x)$
|
||||
|-|-
|
||||
|$0$|$0.41$
|
||||
|$1$|$0.37$
|
||||
|$2$|$0.16$
|
||||
|$3$|$0.05$
|
||||
|$4$|$0.01$
|
||||
|
||||
### a)
|
||||
What is the probability that there are 3 imperfections?
|
||||
$$P(X=3) = 0.05$$
|
||||
|
||||
### b)
|
||||
What is the probability that there is at least one but no more than three imperfections?
|
||||
$$P(X=1 \cup X=2 \cup X=3) = 0.37+0.16+0.05 = 0.58$$
|
||||
|
||||
## 6
|
||||
Software to detect fraud in consumer phone cards tracks the number of metropolitan areas where calls originate each day. It is found that 1% of the legitimate users originate calls from two or more metropolitan areas in a single day. However, 30% of fraudulent users originate calls from two or more metropolitan areas in a single day. The proportion of fraudulent users is 0.01%. If the same user originates calls from two or more metropolitan areas in a single day, what is the probability that the user is fraudulent?
|
||||
|
||||
$F$ is the event that a user is fraudulent, $F^c$ is the event that a user is not fraudulent. $M$ is the event that a user originates calls from two or more metropolitan areas in a single day.
|
||||
|
||||
$$P(F) = 0.0001$$
|
||||
$$P(F^c) = 0.9999$$
|
||||
$$P(M|F) = 0.3$$
|
||||
$$P(M|F^c) = 0.01$$
|
||||
$$P(M) = 0.3 \times 0.0001 + 0.01 \times 0.9999 = 0.01003$$
|
||||
$$P(F|M) = \frac{P(M|F) P(F)}{P(M)} = \frac{0.3 \times 0.0001}{0.01003} = 0.00299$$
|
||||
|
||||
## 7
|
||||
An assembly consists of three mechanical components. Suppose that the probabilities that the first, second, and third components meet specifications are 0.95, 0.98, and 0.99. Assume that the components are independent. Determine the probability mass function of the number of components in the assembly that meet specifications.
|
||||
|
||||
Let $C_1$ be the event that the first component meets specification, $C_2$ be the event that the second component meets specification, $C_3$ be the event that the third component meets specification, and $X$ be the number of components that meet specification:
|
||||
$$P(X=0) = P(C_1 \cap C_2 \cap C_3)= 0.95\times0.98\times0.99 = 0.9217$$
|
||||
$$P(X=1) = P((C_1 \cap C_2 \cap C_3^c) \cup (C_1 \cap C_3 \cap C_2^c) \cup (C_2 \cap C_3 \cap C_1^c))$$
|
||||
$$P(X=1)= 0.0766$$
|
||||
$$P(X=2) = P((C_1 \cap C_2^c \cap C_3^c) \cup (C_2 \cap C_1^c \cap C_3^c) \cup (C_3 \cap C_2^c \cap C_1^c))$$
|
||||
$$P(X=2) = 0.00167$$
|
||||
$$P(X=3) = P(C_1^c \cap C_2^c \cap C_3^c) = 0.05\times 0.02 \times 0.01 = 0.00001$$
|
||||
|
||||
$$p_X(x) =
|
||||
\begin{cases}
|
||||
0.921689 & x=0 \\
|
||||
0.07663 & x=1 \\
|
||||
0.00167 & x=2 \\
|
||||
0.00001 & x=3
|
||||
\end{cases}$$
|
Binary file not shown.
@ -0,0 +1,154 @@
|
||||
# Homework 3 - Aidan Sharpe
|
||||
## 1
|
||||
$$F(x) = \begin{cases}
|
||||
0 & x < 0 \\
|
||||
1 - e^{-7x} & x \ge 0
|
||||
\end{cases}$$
|
||||
|
||||
### a)
|
||||
Find the probability density function of $X$:
|
||||
$$f(x) = {d\over dx} F(x) = \begin{cases}
|
||||
0 & x < 0 \\
|
||||
7e^{-7x} & x \ge 0
|
||||
\end{cases}
|
||||
$$
|
||||
|
||||
### b)
|
||||
Verify that $f(x)$ is a valid density function:
|
||||
$$\int\limits_0^\infty f(x)dx \overset{?}{=} 1$$
|
||||
$$\int\limits_0^\infty 7e^{-7x}dx = \left[-e^{-7x}\Big|_0^\infty\right] = 0 - (-1) = 1$$
|
||||
|
||||
### c)
|
||||
Find $P(X<0.25)$:
|
||||
|
||||
$$F(0.25) = 1-e^{-7(0.25)} = 0.826$$
|
||||
|
||||
### d)
|
||||
Find $P({5\over60} < X < {11\over60})$:
|
||||
$$F\left({11\over60}\right) = 0.723$$
|
||||
$$F\left({5\over60}\right) = 0.442$$
|
||||
$$P\left({5\over60} < X < {11\over60}\right) = 0.723 - 0.442 = 0.281$$
|
||||
|
||||
## 2
|
||||
$$f(x) = \begin{cases}
|
||||
kx^{-3} & x > 1 \\
|
||||
0 & \text{elsewhere}
|
||||
\end{cases}$$
|
||||
|
||||
### a)
|
||||
Find $k$, such that $f(x)$ is a valid density function:
|
||||
$$\int\limits_0^\infty f(x)dx \overset{!}{=} 1$$
|
||||
$$\int\limits_1^\infty kx^{-3}dx = \left[{-k\over 2x^2}\Big|_1^\infty\right] = 0 - {-k\over2}$$
|
||||
$$\therefore k = 2$$
|
||||
|
||||
### b)
|
||||
Find $F(x)$:
|
||||
$$F(x) = \int\limits_{-\infty}^x f(t)dt$$
|
||||
$$F(x) = \begin{cases}
|
||||
1-{1\over x^2} & x > 1 \\
|
||||
0 & \text{elsewhere}
|
||||
\end{cases}$$
|
||||
|
||||
### c)
|
||||
Find $P(X>7)$:
|
||||
$$P(X>7) = F(7) = 0.98$$
|
||||
|
||||
### d)
|
||||
Find $P(5 < X < 12)$:
|
||||
$$P(X < 12) = F(12) = 0.993$$
|
||||
$$P(X < 5) = 0.96$$
|
||||
$$P(5 < X < 12) = F(12) - F(5) = 0.033$$
|
||||
|
||||
## 3
|
||||
$$f(x) = \begin{cases}
|
||||
{1\over5} & 1 < x < 6 \\
|
||||
0 & \text{elsewhere}
|
||||
\end{cases}$$
|
||||
|
||||
### a)
|
||||
Verify that $f(x)$ is a valid probability density function:
|
||||
$$\int\limits_0^\infty f(x)dx \overset{?}{=} 1$$
|
||||
$${1\over5}(6 - 1) = 1$$
|
||||
|
||||
### b)
|
||||
Find $P(2.5 \le X < 3)$:
|
||||
$$P(2.5 \le X < 3) = F(3) - F(2.5) = 0.4 - 0.3 = 0.1$$
|
||||
|
||||
### c)
|
||||
Find $P(X \le 2)$:
|
||||
$$P(X \le 2) = F(2) = 0.4$$
|
||||
|
||||
### d)
|
||||
Find $F(x)$:
|
||||
$$F(x) = \int\limits_{-\infty}^{x} f(t)dt$$
|
||||
$$F(x) = \begin{cases}
|
||||
0 & x < 1 \\
|
||||
{(x-1)\over5} & 1 \le x < 6 \\
|
||||
1 & x \ge 6
|
||||
\end{cases}$$
|
||||
|
||||
## 4
|
||||
A box contains 7 dimes and 5 nickels. Three coins are chosen. $T$ is their total value in cents.
|
||||
|
||||
### a)
|
||||
The set of all possible drawings of coins is:
|
||||
$$\{DDD, DDN, DND, DNN, NDD, NDN, NND, NNN\}$$
|
||||
|
||||
Therefore the following are values for $T$:
|
||||
$$T = \{30, 25, 20, 15\}$$
|
||||
|
||||
### b)
|
||||
Find the probability density function for $T$, $f(x)$:
|
||||
$$P(T = 30) = {{7\choose3}{5\choose0}\over{12\choose3}} = 0.159$$
|
||||
$$P(T = 25) = {{7\choose2}{5\choose1}\over{12\choose3}} = 0.477$$
|
||||
$$P(T = 20) = {{7\choose1}{5\choose2}\over{12\choose3}} = 0.318$$
|
||||
$$P(T = 15) = {{7\choose0}{5\choose3}\over{12\choose3}} = 0.046$$
|
||||
|
||||
$$f(x) = \begin{cases}
|
||||
0.046 & x = 15 \\
|
||||
0.318 & x = 20 \\
|
||||
0.477 & x = 25 \\
|
||||
0.159 & x = 30 \\
|
||||
\end{cases}$$
|
||||
|
||||
### c)
|
||||
Find the CDF for $T$, $F(x)$:
|
||||
$$f(x) = \begin{cases}
|
||||
0 & x < 15 \\
|
||||
0.046 & 15 \le x < 20 \\
|
||||
0.364 & 20 \le x < 25\\
|
||||
0.841 & 25 \le x < 30 \\
|
||||
1 & x \ge 30 \\
|
||||
\end{cases}$$
|
||||
|
||||
## 5
|
||||
|$x$|$f(x)$|
|
||||
|-|-
|
||||
|10|0.08
|
||||
|11|0.15
|
||||
|12|0.30
|
||||
|13|0.20
|
||||
|14|0.20
|
||||
|15|0.07
|
||||
|
||||
Determine the mean number of messages sent per hour
|
||||
$$\sum\limits_x xf(x) = 10(0.08) + 11(0.15) + 12(0.30) + 13(0.20) + 14(0.20) + 15(0.07) = 12.5$$
|
||||
|
||||
## 6
|
||||
Find the expected value for each of the following probability density functions:
|
||||
|
||||
### a)
|
||||
$$f(x) = \begin{cases}
|
||||
x + {1\over2} & 0 < x < 1 \\
|
||||
0 & \text{elsewhere}
|
||||
\end{cases}$$
|
||||
|
||||
$$E[x]=\int\limits_0^1 \left(x+{1\over2}\right)dx = \left[ {x^2 + x \over 2} \Big|_0^1 \right] =1$$
|
||||
|
||||
### b)
|
||||
$$f(x) = \begin{cases}
|
||||
{3\over x^4} & x \ge 1 \\
|
||||
0 & \text{elsewhere}
|
||||
\end{cases}$$
|
||||
|
||||
$$E[x] \int\limits_1^\infty {3\over x^4}dx = \left[ {-1 \over x^3} \Big|_1^\infty \right] = 0 - (-1) = 1$$
|
Binary file not shown.
@ -0,0 +1,208 @@
|
||||
# Homework 5 - Aidan Sharpe
|
||||
|
||||
## 1
|
||||
The finished inside diameter of a piston ring is normally distributed with a mean, $\mu = 10$[cm], and a standard deviation, $\sigma = 0.03$[cm].
|
||||
|
||||
### a)
|
||||
What is the probability that the inside diameter exceeds 10.04[cm]?
|
||||
$$Z = {10.04 - 10 \over 0.03} = {4 \over 3}$$
|
||||
```ipython
|
||||
>>> from scipy.stats import norm
|
||||
>>> z = (10.04 - 10) / 0.03
|
||||
>>> 1 - norm.cdf(z)
|
||||
0.09121121972587254
|
||||
```
|
||||
$$P(X > 10.04) = 0.0912$$
|
||||
|
||||
|
||||
### b)
|
||||
What is the probability that a piston ring will have an inside diameter between 9.98[cm] and 10.02[cm]?
|
||||
$$Z_1 = {9.98 - 10 \over 0.03}$$
|
||||
$$Z_2 = {10.02 - 10 \over 0.03}$$
|
||||
```python
|
||||
>>> from scipy.stats import norm
|
||||
>>> z1 = (9.98 - 10) / 0.03
|
||||
>>> z2 = (10.02 - 10) / 0.03
|
||||
>>> norm.cdf(z2) - norm.cdf(z1)
|
||||
0.49501492490614524
|
||||
```
|
||||
$$P(9.98 < X < 10.02) = 0.4950$$
|
||||
|
||||
### c)
|
||||
What is the probability that a piston ring will have an inside diameter of less than 10[cm]?
|
||||
|
||||
By the definition of a normal distribution:
|
||||
$$P(X < \mu) = 0.5$$
|
||||
|
||||
## 2
|
||||
A research engineer for a tire manufacturer is investigating tire life for a new rubber compound and has built 20 tires and tested them to end-of-life in a road test. The sample mean is $\bar{x} = 60139.7$[km] and the standard deviation, $\sigma = 3645.94$[km]. Calculate a 99% confidence interval for the mean life of all such tires.
|
||||
|
||||
For a 99% confidence interval, $\alpha = 0.01$, and the interval is given by:
|
||||
$$\bar{x} \pm z_{\alpha \over 2} {\sigma \over \sqrt{n}}$$
|
||||
```python
|
||||
>>> from scipy.stats import norm
|
||||
>>> a = 0.01
|
||||
>>> z_a2 = norm.ppf(1 - (a/2))
|
||||
>>> x_bar = 60139.7
|
||||
>>> stddev = 3645.94
|
||||
>>> x_bar + z_a2 * stddev / n**(1/2)
|
||||
62239.66278858252
|
||||
>>> x_bar - z_a2 * stddev / n**(1/2)
|
||||
58039.73721141747
|
||||
```
|
||||
We are 99% certain that the mean life of a tire made with this rubber compound is between 62239.7[km] and 58039.7[km].
|
||||
|
||||
## 3
|
||||
A sample of $n = 25$ joint specimens of a particular type gave a sample mean proportional limit stress of $\bar{x} = 8.6$[MPa] and a sample standard deviation of $s = 0.81$[MPa]. Construct and interpret in context a 95% confidence interval for the true average proportional limit stress of all such joints. Note that the population standard deviation is not known here. Be sure to use the correct confidence interval formulation.
|
||||
|
||||
For a 95% confidence interval, $\alpha = 0.05$, and the interval is given by:
|
||||
$$\bar{x} \pm t^* {s \over \sqrt{n}}$$
|
||||
|
||||
```python
|
||||
>>> from scipy.stats import t
|
||||
>>> n = 25
|
||||
>>> x_bar = 8.6E6
|
||||
>>> s = 0.81E6
|
||||
>>> a = 0.05
|
||||
>>> t_star = t.ppf(1 - (a/2), n)
|
||||
>>> x_bar + t_star * s / n**(1/2)
|
||||
8933645.245546034
|
||||
>>> x_bar - t_star * s / n**(1/2)
|
||||
8266354.754453966
|
||||
```
|
||||
|
||||
We are 95% confident that the mean proportional limit stress for this type of joint specimen is between 8.2[MPa] and 8.9[MPa].
|
||||
|
||||
## 4
|
||||
A sample of 45 pieces of laminate used in the manufacture of circuit boards was selected and the amount of warpage, in inches, under particular conditions was determined for each piece, resulting in a sample mean warpage of $\bar{x} = 0.0631$[in] and a sample standard deviation of $s = 0.0072$[in].
|
||||
|
||||
### a)
|
||||
Construct and interpret in context a 99% confidence interval for the average amount of warpage in all such pieces of laminate.
|
||||
```python
|
||||
>>> from scipy.stats import t
|
||||
>>> x_bar = 0.0631
|
||||
>>> s = 0.0072
|
||||
>>> a = 0.01
|
||||
>>> n = 45
|
||||
>>> t_star = t.ppf(1-a/2, n)
|
||||
>>> x_bar + t_star * s / n**(1/2)
|
||||
0.06598676556860165
|
||||
>>> x_bar - t_star * s / n**(1/2)
|
||||
0.06021323443139835
|
||||
```
|
||||
|
||||
We are 99% certain that the average amount of warpage in all pieces of this type of laminate is between 0.0602 inches and 0.0660 inches.
|
||||
|
||||
### b)
|
||||
Construct and interpret in context a 90% confidence interval for the average amount of warpage in all such pieces of laminate.
|
||||
|
||||
```python
|
||||
>>> from scipy.stats import t
|
||||
>>> x_bar = 0.0631
|
||||
>>> s = 0.0072
|
||||
>>> n = 45
|
||||
>>> a = 0.1
|
||||
>>> t_star = t.ppf(1-a/2, n)
|
||||
>>> x_bar + t_star * s / n**(1/2)
|
||||
0.06490255062920108
|
||||
>>> x_bar - t_star * s / n**(1/2)
|
||||
0.06129744937079893
|
||||
```
|
||||
We are 90% certain that the average amount of warpage in all pieces of this type of laminate is between 0.0613 inches and 0.0649 inches.
|
||||
|
||||
### c)
|
||||
Which interval is wider and why?
|
||||
|
||||
The only ways to increase confidence are by increasing sample size and by increasing the width of the confidence interval. A smaller confidence interval inherintly has a larger uncertainty associated with it. For this reason, the 90% confidence interval is smaller than the 99% confidence interval.
|
||||
## 5
|
||||
For this problem, use the code labeled problem 6 in the file ”hw 5 code” on Canvas. You will explore the width of a confidence interval as the sample size increases. Suppose we are interested in estimating some population parameter $\mu$. We will fix the population parameter to be $\mu = 75$. Of course, in practice we would not know $\mu$, otherwise we would not need to estimate it. Assume the population standard deviation is $\sigma = 13$.
|
||||
|
||||
**To find the width of an interval, subtract the lower bound from the upper bound**
|
||||
```python
|
||||
>>> from scipy.stats import norm
|
||||
>>> import numpy as np
|
||||
>>> def sample_mean(sample_size):
|
||||
... sample = np.random.chisquare(df=75, size=samplesize)
|
||||
... return np.mean(sample)
|
||||
```
|
||||
|
||||
### a)
|
||||
Let $n=10$. Run `sample_mean(10)` and record the value of $\bar{x}$. Use $\bar{x}$ to construct a 95% confidence interval for $\mu$.
|
||||
```python
|
||||
>>> n = 10
|
||||
>>> x_bar = sample_mean(n)
|
||||
>>> x_bar # Print out the sample mean for n=10
|
||||
73.32164347142393
|
||||
>>> a = 0.05
|
||||
>>> stddev = 13
|
||||
>>> z_a2 = norm.ppf(1 - a/2)
|
||||
>>> x_bar + z_a2 * stddev / n**(1/2) # Find the upper bound for the CI
|
||||
81.37897889138323
|
||||
>>> x_bar - z_a2 * stddev / n**(1/2) # Find the lower bound for the CI
|
||||
65.26430805146462
|
||||
```
|
||||
The 95% confidence interval for $n=10$ is (65.26, 81.38).
|
||||
|
||||
### b)
|
||||
Do the same for $n=50$.
|
||||
```python
|
||||
>>> n = 50
|
||||
>>> x_bar = sample_mean(n)
|
||||
>>> x_bar # Print out the sample mean for n=50
|
||||
76.17226231360712
|
||||
>>> a = 0.05
|
||||
>>> stddev = 13
|
||||
>>> z_a2 = norm.ppf(1 - a/2)
|
||||
>>> x_bar + z_a2 * stddev / n**(1/2) # Find the upper bound for the CI
|
||||
79.77561225691628
|
||||
>>> x_bar - z_a2 * stddev / n**(1/2) # Find the lower bound for the CI
|
||||
72.56891237029797
|
||||
```
|
||||
The 95% confidence interval for $n=50$ is (72.57, 79.78).
|
||||
|
||||
### c)
|
||||
Do the same for $n=500$.
|
||||
```python
|
||||
>>> n=500
|
||||
>>> x_bar = sample_mean(n)
|
||||
>>> x_bar # Print out the sample mean for n=500
|
||||
74.93800434978642
|
||||
>>> x_bar + z_a2 * stddev / n**(1/2) # Find the upper bound for the CI
|
||||
76.07748365253597
|
||||
>>> x_bar - z_a2 * stddev / n**(1/2) # Find the lower bound for the CI
|
||||
73.79852504703688
|
||||
```
|
||||
The 95% confidence interval for $n=500$ is (73.80, 76.08).
|
||||
|
||||
### d)
|
||||
Do the same for $n=5000$.
|
||||
```python
|
||||
>>> n=5000
|
||||
>>> x_bar = sample_mean(n)
|
||||
>>> x_bar # Print out the sample mean for n=5000
|
||||
74.92683635507494
|
||||
>>> x_bar + z_a2 * stddev / n**(1/2) # Find the upper bound for the CI
|
||||
75.28717134940585
|
||||
>>> x_bar - z_a2 * stddev / n**(1/2) # Find the lower bound for the CI
|
||||
74.56650136074403
|
||||
```
|
||||
The 95% confidence interval for $n=5000$ is (74.57, 75.29).
|
||||
|
||||
### e)
|
||||
Do the same for $n=50000$.
|
||||
```python
|
||||
>>> n=50000
|
||||
>>> x_bar = sample_mean(n)
|
||||
>>> x_bar # Print out the sample mean for n=50000
|
||||
75.03170012357572
|
||||
>>> x_bar + z_a2 * stddev / n**(1/2) # Find the upper bound for the CI
|
||||
75.14564805385068
|
||||
>>> x_bar - z_a2 * stddev / n**(1/2) # Find the lower bound for the CI
|
||||
74.91775219330076
|
||||
```
|
||||
The 95% confidence interval for $n=50000$ is (74.92, 75.15).
|
||||
|
||||
### f)
|
||||
What do you notice abou the width of the confidence interval as the sample size increases?
|
||||
|
||||
As the sample size increases, the width of the confidence interval decreases quickly at first, but quickly yields diminishing returns.
|
Binary file not shown.
@ -0,0 +1,143 @@
|
||||
# Homework 6 - Aidan Sharpe
|
||||
|
||||
## 1
|
||||
Using a mathematical model, social analysts estimate that, on average, a US adult has social ties with 634 people. A survey of 1700 randomly selected US adults who are cell phone users find that the average number of social ties for the cell phone users in the sample was 664 with a standard deviation of 500. Does the sample provide evidence that the average number of social ties for a cell phone user is significantly different from 634, the hypothesized number for all US adults? Use $\alpha = 0.05$.
|
||||
|
||||
$$\mu = 634$$
|
||||
$$\bar{x} = 664$$
|
||||
$$s = 500$$
|
||||
$$\alpha = 0.05$$
|
||||
|
||||
### a)
|
||||
$H_0$: $\mu = 634$
|
||||
|
||||
$H_a$: $\mu \ne 634$
|
||||
|
||||
### b)
|
||||
$$t^* = {664 - 634 \over {500 \over \sqrt{1700}}} = 2.47386$$
|
||||
|
||||
### c)
|
||||
```python
|
||||
>>> import numpy as np
|
||||
>>> import scipy.stats as st
|
||||
>>> import matplotlib.pyplot as plt
|
||||
|
||||
>>> def p_value(test_statistic, sample_size):
|
||||
... test_statistic = abs(test_statistic)
|
||||
... return 1 - st.t.cdf(test_statistic, sample_size - 1)
|
||||
|
||||
>>> n = 1700
|
||||
>>> ts = (664 - 634) / (500 / n**(1/2))
|
||||
>>> p_value(ts, n)
|
||||
0.0067315863612649185
|
||||
```
|
||||
|
||||
### d)
|
||||
Since $0.00673 < 0.05$, we have enough evidence to reject the proposition that the average number of social ties of a US adult is 634 people.
|
||||
|
||||
## 2
|
||||
The Edison Electric Institute has published figures on the number of kilowatt hours used annually by various home appliances. It is claimed that a vacuum cleaner uses an average of 40 kilowatt hours per year. If a random sample of 14 homes included in a planned study indicates that vacuum cleaners use an average of 36 kilowatt hours per year with a standard deviation of 10.5 kilowatt hours, does this suggest at the 0.05 level of significance that vacuum cleaners use, on average, less than 40 kilowatt hours annually? Since the sample size is small, we will assume the population of kilowatt hours to be normal.
|
||||
|
||||
$$\mu_0 = 40$$
|
||||
$$\bar{x} = 36$$
|
||||
$$s = 10.5$$
|
||||
$$n = 14$$
|
||||
$$\alpha = 0.05$$
|
||||
|
||||
Null and alternative hypothesis:
|
||||
|
||||
$H_0$: $\mu = 40$
|
||||
|
||||
$H_a$: $\mu < 40$
|
||||
|
||||
$$t^* = {36 - 40 \over {10.5 \over \sqrt{14}}} = -1.42539$$
|
||||
|
||||
Using the same p-value function from the previous exercise:
|
||||
```python
|
||||
>>> n = 14
|
||||
>>> ts = (36 - 40) / (10.5 / n**(1/2))
|
||||
>>> p_value(ts, n)
|
||||
0.08880497181576619
|
||||
```
|
||||
Since the p-value is greater than $\alpha$, we do not have enough evidence to reject the proposition that the average power consumption of a vacuum cleaner is 40 kilowatt hours per year.
|
||||
|
||||
## 3
|
||||
The brightness of a television picture tube can be evaluated by measuring the amount of current required to achieve a particular brightness level. A sample of 65 tubes results in $\bar{x} = 317.2$ and $s = 15.7$. Find (in microamps) a 99% confidence interval on mean current required.
|
||||
|
||||
$$s = 15.7$$
|
||||
$$\bar{x} = 317.2$$
|
||||
$$n = 65$$
|
||||
$$\alpha = 0.01$$
|
||||
|
||||
$$\bar{x} \pm t^*{s \over \sqrt{n}}$$
|
||||
```python
|
||||
>>> from scipy.stats import t
|
||||
>>> s = 15.7
|
||||
>>> x_bar = 317.2
|
||||
>>> n = 65
|
||||
>>> a = 0.01
|
||||
>>> ts = t.ppf(1 - (a/2), n)
|
||||
>>> x_bar + ts * s / n**(1/2)
|
||||
322.3674842907025
|
||||
>>> x_bar - ts * s / n**(1/2)
|
||||
312.03251570929746
|
||||
```
|
||||
We are 99% confident that the mean current draw to achieve this particular brightness is between 312.033[$\mu$A] and 322.367[$\mu$A].
|
||||
|
||||
## 4
|
||||
Consider the scenario in the previous problem. Suppose that the design engineer claims that this tube will require at least 300 microamps of current to produce the desired brightness level. Formulate and test an appropriate hypothesis to confirm this claim using $\alpha = 0.05$.
|
||||
$$\bar{x} = 317.2$$
|
||||
$$s = 15.7$$
|
||||
$$n = 65$$
|
||||
$$\alpha = 0.05$$
|
||||
$$\mu_0 = 300$$
|
||||
|
||||
$H_0$: $\mu = 300$
|
||||
|
||||
$H_a$: $\mu > 300$
|
||||
|
||||
$$t^* = {317.2 - 300 \over {15.7 \over \sqrt{65}}} = 4.341$$
|
||||
|
||||
```python
|
||||
>>> from scipy.stats import t
|
||||
>>> n = 15.7
|
||||
>>> x_bar = 317.2
|
||||
>>> mu0 = 300
|
||||
>>> s = 15.7
|
||||
>>> ts = (x_bar - mu0) / (s / n**(1/2))
|
||||
>>> t.sf(abs(ts), n)
|
||||
0.00026342753958306323
|
||||
```
|
||||
Since the p-value is less than $\alpha$, we can reject the null hypothesis, meaning that the average tube will draw at least 300[$\mu$A].
|
||||
|
||||
## 5
|
||||
A new steel plant has gone into production and markets a specific grade of steel. It is necessary to determine if the mean tensile strength of the new product differs significantly from the industry standard. A sample of 40 is taken from the new producer and yields a mean tensile strength value of $\bar{x} = 48950$ psi with a standard deviation of $s = 2700$ psi. Determine if the mean ultimate tensile strength of the new product differs significantly from the industry standard, $\mu = 50000$psi. Use $\alpha = 0.01$
|
||||
|
||||
$$n = 40$$
|
||||
$$s = 2700$$
|
||||
$$\bar{x} = 48950$$
|
||||
$$\mu_0 = 50000$$
|
||||
$$\alpha = 0.01$$
|
||||
|
||||
$H_0$: $\mu = 50000$
|
||||
|
||||
$H_a$: $\mu \ne 50000$
|
||||
|
||||
$$t^* = {48950 - 50000 \over {2700 \over \sqrt{40}}} = -2.4595$$
|
||||
```python
|
||||
>>> from scipy.stats import t
|
||||
>>> n = 40
|
||||
>>> s = 2700
|
||||
>>> x_bar = 48950
|
||||
>>> mu0 = 50000
|
||||
>>> a = 0.01
|
||||
>>> ts = (x_bar - mu0) / (s / n**(1/2))
|
||||
>>> t.sf(abs(ts), n)
|
||||
0.00916542992087841
|
||||
```
|
||||
Since the p-value is less than but very close to $\alpha$, there is technically enough evidence to reject the proposition that the tensile strength meets the industry standard, however, more testing should be done to ensure this.
|
||||
|
||||
## 6
|
||||
Would your conclusion from Problem 5 change if we used a significance level of $\alpha = 0.05$?
|
||||
|
||||
If $\alpha$ was instead 0.05, the p-value would be much lower than the threshold required, and therefore there is enough evidence to reject the proposition that the tensile strength of this steel meets the industry standard.
|
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
\relax
|
||||
\gdef \@abspage@last{1}
|
@ -0,0 +1,76 @@
|
||||
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022/CVE-2023-32700 patched) (preloaded format=pdflatex 2023.9.26) 11 NOV 2023 20:48
|
||||
entering extended mode
|
||||
\write18 enabled.
|
||||
%&-line parsing enabled.
|
||||
**/tmp/nvim.sharpe/MpyYyC/0
|
||||
(/tmp/nvim.sharpe/MpyYyC/0
|
||||
LaTeX2e <2022-06-01> patch level 5
|
||||
L3 programming layer <2022-12-17>
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/base/report.cls
|
||||
Document Class: report 2021/10/04 v1.4n Standard LaTeX document class
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo
|
||||
File: size10.clo 2021/10/04 v1.4n Standard LaTeX file (size option)
|
||||
)
|
||||
\c@part=\count185
|
||||
\c@chapter=\count186
|
||||
\c@section=\count187
|
||||
\c@subsection=\count188
|
||||
\c@subsubsection=\count189
|
||||
\c@paragraph=\count190
|
||||
\c@subparagraph=\count191
|
||||
\c@figure=\count192
|
||||
\c@table=\count193
|
||||
\abovecaptionskip=\skip47
|
||||
\belowcaptionskip=\skip48
|
||||
\bibindent=\dimen140
|
||||
)
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def
|
||||
File: l3backend-pdftex.def 2022-10-26 L3 backend support: PDF output (pdfTeX)
|
||||
\l__color_backend_stack_int=\count194
|
||||
\l__pdf_internal_box=\box51
|
||||
)
|
||||
(./Homework-07.aux)
|
||||
\openout1 = `Homework-07.aux'.
|
||||
|
||||
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 3.
|
||||
LaTeX Font Info: ... okay on input line 3.
|
||||
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 3.
|
||||
LaTeX Font Info: ... okay on input line 3.
|
||||
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 3.
|
||||
LaTeX Font Info: ... okay on input line 3.
|
||||
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 3.
|
||||
LaTeX Font Info: ... okay on input line 3.
|
||||
LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 3.
|
||||
LaTeX Font Info: ... okay on input line 3.
|
||||
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 3.
|
||||
LaTeX Font Info: ... okay on input line 3.
|
||||
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 3.
|
||||
LaTeX Font Info: ... okay on input line 3.
|
||||
LaTeX Font Info: External font `cmex10' loaded for size
|
||||
(Font) <7> on input line 7.
|
||||
LaTeX Font Info: External font `cmex10' loaded for size
|
||||
(Font) <5> on input line 7.
|
||||
[1
|
||||
|
||||
{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}]
|
||||
(./Homework-07.aux) )
|
||||
Here is how much of TeX's memory you used:
|
||||
451 strings out of 476182
|
||||
8509 string characters out of 5796581
|
||||
1852793 words of memory out of 6000000
|
||||
20838 multiletter control sequences out of 15000+600000
|
||||
513497 words of font info for 36 fonts, out of 8000000 for 9000
|
||||
1137 hyphenation exceptions out of 8191
|
||||
34i,5n,38p,945b,107s stack positions out of 10000i,1000n,20000p,200000b,200000s
|
||||
</usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts
|
||||
/cm/cmbx12.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cm
|
||||
mi10.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi7.pf
|
||||
b></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb></usr
|
||||
/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr7.pfb>
|
||||
Output written on Homework-07.pdf (1 page, 59220 bytes).
|
||||
PDF statistics:
|
||||
33 PDF objects out of 1000 (max. 8388607)
|
||||
19 compressed objects within 1 object stream
|
||||
0 named destinations out of 1000 (max. 500000)
|
||||
1 words of extra memory for PDF output out of 10000 (max. 10000000)
|
||||
|
@ -0,0 +1,102 @@
|
||||
# Homework 7 - Aidan Sharpe
|
||||
|
||||
## Problem 1
|
||||
A photoconductor film is manufactured at a nominal thickness of 25 mils. The product engineer wishes to decrease the energy absorption of the film, and he believes this can be achieved by reducing the thickness of the film to 20 mils. Eight samples of each film thickness are manufactured in a pilot production process, and the film absorption (in microjules per square inch) is measured. For the 25-mil film the sample data result is $\bar{x}_1 = 1.17$ and $s_1 = 0.10$. While for the 20-mil film, the data yield $\bar{x}_2 = 1.07$ and $s_2 = 0.09$. Note that an increase in film speed would lower the value of the observation in microjules per square inch. Do the data support the claim that reducing the film thickness increases the mean speed of the film? Use $\alpha = 0.10$ and assume the two population variances are equal and the underlying population of film speed is normally distributed.
|
||||
|
||||
$H_0$: $\mu_1 = \mu_2$
|
||||
$H_a$: $\mu_1 \ne \mu_2$
|
||||
|
||||
```python
|
||||
>>> import scipy.stats as st
|
||||
>>> def p_value(test_statistic, sample_size_1, sample_size_2):
|
||||
... df = sample_size_1 + sample_size_2 - 2
|
||||
... test_statistic = abs(test_statistic)
|
||||
... return 1 - st.t.cdf(test_statistic, df)
|
||||
|
||||
>>> def tstat(x1, x2, sp, n1, n2):
|
||||
... return (x1 - x2) / (sp * (1/n1 + 1/n2)**0.5)
|
||||
|
||||
>>> def sp(x1, x2, s1, s2, n1, n2):
|
||||
... return (((n1-1)*(s1**2) + (n2-1)*(s2**2)) / (n1 + n2 - 2))**0.5
|
||||
|
||||
>>> s_p = sp(x1, x2, s1, s2, n1, n2)
|
||||
>>> t_star = tstat(x1, x2, s_p, n1, n2)
|
||||
>>> p_value(t_star, n1, n2)
|
||||
0.02704853389386974
|
||||
```
|
||||
Since the p-value is less than $\alpha$, we have enough evidence to reject the notion that changing the thickness of the film has no effect on its energy absorbtion.
|
||||
|
||||
## Problem 2
|
||||
A QC technician measures the quality for two lots of product. In the first lot, 20 units are tested and the average measurement is 75 with sample variance 210. In the second lot, 25 units are tested with an average measurement of 70 and sample variance of 130. Given that higher is better for this quality measurement, test the hypothesis that the quality of the second lot is lower that that of the first lot using $\alpha = 0.05$. You may assume the two lots come from populations with the same variance.
|
||||
|
||||
$H_0$: $\mu_a = \mu_b$
|
||||
$H_a$: $\mu_a \ne \mu_b$
|
||||
|
||||
```python
|
||||
>>> n1 = 20
|
||||
>>> n2 = 25
|
||||
>>> x1 = 75
|
||||
>>> x2 = 70
|
||||
>>> s1 = 210**0.5
|
||||
>>> s2 = 130**0.5
|
||||
>>> s_p = sp(x1, x2, s1, s2, n1, n2)
|
||||
>>> t_star = tstat(x1, x2, s_p, n1, n2)
|
||||
>>> p_value(t_star, n1, n2)
|
||||
0.10092241987763473
|
||||
```
|
||||
|
||||
Since the p-value is greater than $\alpha$, there is not enough evidence to suggest that there is a difference in quality between the two lots.
|
||||
|
||||
## Problem 3
|
||||
Ace Explosive Demolition is understandably concerned with burn times for the fuses that they use in their work. Their two suppliers of fuses both deliver their fuses on spools that contain 10,000 feet of fuse. Thirty-two fuses of 30 feet in length are prepared from each supplier’s pool. The fuses are then lit, and each fuse’s elapsed burn time is carefully measured. Supplier A’s sample average and sample variance are 30.62 and .384 seconds, respectively. Supplier B’s sample average and sample variance are 31.37 seconds and 0.185 seconds, respectively. Does the sample suggest that the mean burn time for supplier A is different than that for supplier B? use $\alpha = 0.05$
|
||||
|
||||
$H_0$: $\mu_a = \mu_b$
|
||||
$H_a$: $\mu_a \ne \mu_b$
|
||||
|
||||
```python
|
||||
>>> n1 = 32
|
||||
>>> n2 = 32
|
||||
>>> x1 = 30.62
|
||||
>>> x2 = 31.37
|
||||
>>> s1 = (0.384)**0.5
|
||||
>>> s2 = (0.185)**0.5
|
||||
>>> s_p = sp(x1, x2, s1, s2, n1, n2)
|
||||
>>> t_star = tstat(x1, x2, s_p, n1, n2)
|
||||
>>> p_value(t_star, n1, n2)
|
||||
2.3757646183675263e-07
|
||||
```
|
||||
|
||||
Since the p-value is very close to zero, much smaller than $\alpha$, sample evidence suggests that the mean burn time for supplier A is not different than that for supplier B.
|
||||
|
||||
## Problem 4
|
||||
Consider the scenario stated in Problem 3. If $H_0$ is true and we conduct 7150 tests using 7150 different samples, how many (if any) of the individual tests would you expect to show a significant result just by random chance
|
||||
|
||||
Adjusting $n_1$ and $n_2$:
|
||||
|
||||
```python
|
||||
>>> n1 = 7150
|
||||
>>> n2 = 7150
|
||||
>>> s_p = sp(x1, x2, s1, s2, n1, n2)
|
||||
>>> s_p
|
||||
0.5333854141237835
|
||||
```
|
||||
|
||||
With this many samples there is a little over a 50% chance that a significant result shows up.
|
||||
|
||||
## Problem 5
|
||||
A study was conducted to determine if a certain treatment has any effect on the amount of metal removed in a pickling operation. A random sample of 50 pieces was immersed in a bath for 24 hours without the treatment, yielding an average of 12.2 millimeters of metal removed and a sample variance of 5.4 millimeters. A second sample of 75 pieces was exposed to the treatment, followed by the 24-hour immersion in the bath, resulting in an average removal of 11.1 millimeters of metal with a sample variance of 4.8 millimeters. Does the treatment appear to reduce the mean amount of metal removed? Use $\alpha = 0.01$.
|
||||
|
||||
```python
|
||||
>>> n1 = 50
|
||||
>>> n2 = 75
|
||||
>>> x1 = 12.2
|
||||
>>> x2 = 11.1
|
||||
>>> s1 = 5.4**0.5
|
||||
>>> s2 = 4.8**0.5
|
||||
>>> s_p = sp(x1, x2, s1, s2, n1, n2)
|
||||
>>> t_star = tstat(x1, x2, s_p, n1, n2)
|
||||
>>> p_value(t_star, n1, n2)
|
||||
0.004138707985700818
|
||||
```
|
||||
|
||||
Since the p-value is less than $\alpha$, we have enough evidence to reject the notion that treatment has no effect on the amount of metal removed.
|
Binary file not shown.
@ -0,0 +1,15 @@
|
||||
\documentclass{report}
|
||||
|
||||
\begin{document}
|
||||
\section*{Homework 7 - Aidan Sharpe}
|
||||
|
||||
\subsection*{Problem 1}
|
||||
A photoconductor film is manufactured at a nominal thickness of 25 mils. The product engineer wishes to decrease the energy absorption of the film, and he believes this can be achieved by reducing the thickness of the film to 20 mils. Eight samples of each film thickness are manufactured in a pilot production process, and the film absorption (in microjules per square inch) is measured. For the 25-mil film the sample data result is $\bar{x}_1 = 1.17$ and $s_1 = 0.10$. While for the 20-mil film, the data yield $\bar{x}_2 = 1.07$ and $s_2 = 0.09$. Note that an increase in film speed would lower the value of the observation in microjules per square inch. Do the data support the claim that reducing the film thickness increases the mean speed of the film? Use $\alpha = 0.10$ and assume the two population variances are equal and the underlying population of film speed is normally distributed.
|
||||
|
||||
\begin{itemize}
|
||||
\item[$H_0$:] $\mu = \mu_0$
|
||||
\item[$H_a$:] $\mu < \mu_0$
|
||||
\end{itemize}
|
||||
|
||||
|
||||
\end{document}
|
@ -0,0 +1,121 @@
|
||||
# Homework 8 - Aidan Sharpe
|
||||
|
||||
## 1
|
||||
The mean pull-off force of a connector depends on cure time.
|
||||
|
||||
### a)
|
||||
State the null and alternative hypotheses used to demonstrate that the pull-off force is below 20 newtons.
|
||||
|
||||
$H_0$: $\mu = 20$[N]
|
||||
$H_a$: $\mu < 20$[N]
|
||||
|
||||
### b)
|
||||
Assume that the previous test does not reject the null hypothesis. Does this result provide strong enough evidence that the pull-off force is greater than or equal to 20 newtons? Please explain.
|
||||
|
||||
Failing to reject the null hypothesis does not mean there is enough evidence to confirm it, it simply leaves that possibility open. Additionally, failing to reject the null hypothesis does not automatically mean that we reject the alternative hypothesis.
|
||||
|
||||
## 2
|
||||
According to Chemical Engineering, an important property of fiber is its water absorbency. The average percent absorbency of 27 randomly selected pieces of cotton fiber was found to be 21.2 with a standard deviation of 1.5. A random sample of 23 pieces of acetate yielded an average percent of 12 with a standard deviation of 1.25. Use a Confidence Interval to determine whether there is strong evidence that the population mean percent absorbency is significantly higher for cotton fiber than for acetate? Assume that the percent absorbency is approximately normally distributed and that the population variances in percent absorbency for the two fibers are the same. Let $\alpha = 0.01$
|
||||
|
||||
||Sample 1|Sample 2|
|
||||
|-|-|-
|
||||
|$n$|27|23
|
||||
|$\bar{x}$|21.2|12
|
||||
|$s$|1.5|1.25
|
||||
|
||||
99% confidence interval for sample 1:
|
||||
```python
|
||||
>>> from scipy.stats import norm
|
||||
>>> a = 0.01
|
||||
>>> z_a2 = norm.ppf(1 - (a/2))
|
||||
>>> x_bar = 21.2
|
||||
>>> s = 1.5
|
||||
>>> n = 27
|
||||
>>> ci = [x_bar - z_a2*s/n**0.5, x_bar + z_a2*s/n**0.5]
|
||||
>>> ci
|
||||
[20.45642212910476, 21.94357787089524]
|
||||
```
|
||||
|
||||
99% confidence interval for sample 2:
|
||||
```python
|
||||
>>> from scipy.stats import norm
|
||||
>>> a = 0.01
|
||||
>>> z_a2 = norm.ppf(1 - (a/2))
|
||||
>>> x_bar = 12
|
||||
>>> s = 1.25
|
||||
>>> n = 23
|
||||
>>> ci = [x_bar - z_a2*s/n**0.5, x_bar + z_a2*s/n**0.5]
|
||||
>>> ci
|
||||
[11.328628077574322, 12.671371922425678]
|
||||
```
|
||||
|
||||
Since there is no overlap between the confidence intervals, there is significantly different absorbency between cotton fiber and acetate.
|
||||
|
||||
## 3
|
||||
A study of asthmatics measured the peak expiratory flow rate (basically, a person’s maximum ability to exhale) before and after a walk on a cold winter’s day for a random sample of nine asthmatics.
|
||||
|
||||
|Subject|Before|After|Difference
|
||||
|-|-|-|-
|
||||
|1|312|300|12
|
||||
|2|242|201|41
|
||||
|3|340|232|108
|
||||
|4|388|312|76
|
||||
|5|296|220|76
|
||||
|6|254|256|-2
|
||||
|7|31|328|63
|
||||
|8|402|330|72
|
||||
|9|290|231|59
|
||||
|$\bar{x}$|323.89|267.78|56.11
|
||||
|$s$|59.83|50.01|34.17
|
||||
|
||||
### a)
|
||||
Using a two-sample t-test: Do the data suggest that there is a difference between the peak
|
||||
expiratory flow rate before vs after a walk on a cold winter’s day for asthamtics? Use $\alpha = 0.01$
|
||||
|
||||
```python
|
||||
>>> import scipy.stats as st
|
||||
|
||||
>>> def p_value(tstat, n1, n2):
|
||||
... df = n1 + n2 - 2
|
||||
... tstat = abs(tstat)
|
||||
... return 1 - st.t.cdf(tstat, df)
|
||||
|
||||
>>> def tstar(x1, x2, sp, n1, n2):
|
||||
... return (x1 - x2) / (sp * (1/n1 + 1/n2)**0.5)
|
||||
|
||||
>>> def sp(x1, x2, s1, s2, n1, n2):
|
||||
... return (((n1-1)*(s1**2) + (n2-1)*(s2**2)) / (n1 + n2 - 2))**0.5
|
||||
|
||||
>>> x1 = 323.89
|
||||
>>> x2 = 267.78
|
||||
>>> s1 = 59.83
|
||||
>>> s2 = 50.01
|
||||
>>> n1 = 9
|
||||
>>> n2 = 9
|
||||
>>> s_p = sp(x1, x2, s1, s2, n1, n2)
|
||||
>>> t_star = tstar(x1, x2, s_p, n1, n2)
|
||||
>>> p_value(t_star, n1, n2)
|
||||
0.02320508093086404
|
||||
```
|
||||
|
||||
Since the p-value is greater than $\alpha$, we do not have enough evidence to reject the notion that going on a walk on a cold winter's day has no effect on the expiratory rate for asthmatics.
|
||||
|
||||
### b)
|
||||
Using a paired t-test: Does the data suggest that there is a difference between the peak expiratory flow rate before vs after a walk on a cold winter’s data for asthmatics? Use $\alpha = 0.01$
|
||||
|
||||
Using a paired t-test, the degrees of freedom in the `p_value(tstat, n1, n2)` function must be adjusted.
|
||||
```python
|
||||
>>> def p_value(tstat, n1, n2):
|
||||
... df = (n1 + n2)/2 - 2
|
||||
... return 1 - st.t.cdf(tstat, df)
|
||||
|
||||
>>> p_value(t_star, n1, n2)
|
||||
0.03387016598071013
|
||||
```
|
||||
|
||||
Using a paired t-test, the p-value increases, but our conclusion does not change.
|
||||
|
||||
### c)
|
||||
Are the conclusions for the two-sample t-test and the paired t-test consistent? If not, what could be the reason?
|
||||
|
||||
While the conclusions are the same, it seems possible for the conclusions to be different in some scenarios. The paired t-test takes into account the persistent sample population, which changes the degrees of freedom for the p-value.
|
Binary file not shown.
@ -0,0 +1,53 @@
|
||||
# Homework 10 - Aidan Sharpe
|
||||
|
||||
## 1
|
||||
The titanium content in an aircraft-grade alloy is an important discriminant of strength. A sample of 10 test coupns reveals the following titanium content in percent:
|
||||
|
||||
| Coupon | Titanium Content |
|
||||
| ------ | ---------------- |
|
||||
| 1 | 8.30% |
|
||||
| 2 | 8.09% |
|
||||
| 3 | 8.99% |
|
||||
| 4 | 8.60% |
|
||||
| 5 | 8.40% |
|
||||
| 6 | 8.35% |
|
||||
| 7 | 8.36% |
|
||||
| 8 | 8.75% |
|
||||
| 9 | 8.91% |
|
||||
| 10 | 8.05% |
|
||||
|
||||
Suppose that the distribution of titanium content is symmetric and continuous. Does the sample data suggest that the mean titanium content differs significantly from 8.5%? Use $\alpha = 0.05$
|
||||
|
||||
```python
|
||||
>>> coupons = [8.3, 8.09, 8.99, 8.60, 8.40, 8.35, 8.36, 8.75, 8.91, 8.05]
|
||||
>>> mu0 = 8.5
|
||||
|
||||
# Find the difference between each sample and mu0
|
||||
>>> differences = [xi - mu0 for xi in coupons]
|
||||
|
||||
# Find the absolute differences
|
||||
>>> abs_diffs = [abs(x) for x in differences]
|
||||
|
||||
# Sort the differences in ascending order
|
||||
>>> s_diffs = sorted(abs_diffs)
|
||||
|
||||
# Turn the sorted order into a ranked list
|
||||
>>> ranks = [abs_diffs.index(x) + 1 for x in s_diffs]
|
||||
|
||||
# Find the ranks corresponding to positive differences
|
||||
>>> p_ranks = [ranks[i] if differences[i] > 0 else 0 for i in range(len(differences))]
|
||||
|
||||
# Find the ranks corresponding to negative differences
|
||||
>>> n_ranks = [ranks[i] if differences[i] < 0 else 0 for i in range(len(differences))]
|
||||
|
||||
# Find the positive and negative rank sums
|
||||
>>> wp = sum(p_ranks)
|
||||
>>> wn = sum(n_ranks)
|
||||
|
||||
# Find the test statistic
|
||||
>>> w_observed = min(wp, wn)
|
||||
>>> w_observed
|
||||
22
|
||||
```
|
||||
|
||||
For a two-sided signed rank test with $\alpha = 0.05$ and 10 samples, $w_\alpha^*$ is 8. Since 22 is greater than 8, we do not have enough evidence to suggest that the mean titanium content differs from 8.5%.
|
Binary file not shown.
Reference in New Issue
Block a user