Shad3yz

Untitled

Jul 21st, 2020
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Latex 19.96 KB | None | 0 0
  1. \documentclass[12pt]{exam}
  2. \usepackage[utf8]{inputenc}
  3. \usepackage[margin=1in]{geometry}
  4. \usepackage{amsmath,amsthm,amssymb}
  5. \usepackage{multicol}
  6. \usepackage{graphicx}
  7. \usepackage{float}
  8. \usepackage{parskip}
  9. \usepackage[framed,numbered,autolinebreaks,useliterate]{mcode}
  10. \graphicspath{ {./images/} }
  11. \newcommand{\class}{Mathematics (MTH 225B)}
  12. \newcommand{\term}{Spring 2020}
  13. \newcommand{\examnum}{Final Exam Solution}
  14. \newcommand{\examdate}{7/6/2020}
  15. \newcommand\ddfrac[2]{\frac{\displaystyle #1}{\displaystyle #2}}
  16. \pagestyle{head}
  17. \runningheader{\class}{\examnum\ - Page \thepage\ of \numpages}{\examdate}
  18. \runningheadrule
  19. \renewcommand{\theenumi}{\alph{enumi}}
  20. \renewcommand*\labelenumi{(\theenumi)}
  21.  
  22. \begin{document}
  23.  
  24. \noindent
  25. \begin{tabular*}{\textwidth}{l @{\extracolsep{\fill}} r @{\extracolsep{6pt}} l}
  26. \textbf{\class} & \textbf{Name:} & \makebox[2in]{Youssef Walid Hassan}\\
  27. \textbf{\term} &&\\
  28. \textbf{\examnum} &&\\
  29. \textbf{\examdate} &&\\
  30. \end{tabular*}\\
  31. \
  32. \rule[2ex]{\textwidth}{2pt}
  33.  
  34.  
  35. \textbf{\underline{Question 1}}
  36.  
  37. \textbf{[I] One packet:} We can model this as a Geometric Random Variable or as a special Bernoulli Process Random Variable as it represents a set of successive failures and then a success at the end.
  38.  
  39. $X$: the number of trials required for the packet to reach Samira.\
  40. \begin{enumerate}
  41. \item The expected number of trials of a Geometric Random Variable is known to be: $E[X] = 1/p$, where $0<p<1$.\
  42.  
  43. \begin{figure}[H]
  44. \centering
  45. \includegraphics[width=410px]{prob1a}
  46. \caption{The expected number of trials of transferring one packet - part (a)}
  47. \end{figure}
  48.  
  49. The Octave code for plotting the curve:
  50.  
  51. \begin{lstlisting}
  52. p = [0.01:0.0001:1];
  53. plot(p, 1./p, 'LineWidth', 1.5);
  54. xlabel("p: the probability of success of a trial");
  55. ylabel("E[X]: the expected number of trials");
  56. title("Expected number of trials to successfully send a packet");
  57. grid on;
  58. \end{lstlisting}
  59.  
  60. \item The distribution of $X$ follows a Geometric Random Variable distribution which is expressed by $f(x) = q^{x-1} \cdot p$.
  61.  
  62. \begin{figure}[H]
  63. \centering
  64. \includegraphics[width=450px]{prob1b}
  65. \caption{f(x): the pdf of X - part (b)}
  66. \end{figure}
  67.  
  68. The Octave code for the plot above:
  69.  
  70. \begin{lstlisting}
  71. hold on;
  72. xlabel("X: the number of trials");
  73. ylabel("f(x): probability mass function of X");
  74. for p = 0.2:0.2:0.8
  75.  x = [1:0.1:12];
  76.  fx = (1-p).^(x.-1) * p;
  77.  plot(x, fx, 'LineWidth', 1.5);
  78. endfor
  79. legend("p = 0.2", "p = 0.4", "p = 0.6", "p = 0.8");
  80. hold off;
  81. \end{lstlisting}
  82.  
  83. \textbf{[II] Simulation:} \item We can generate the plot by looping through $p$ from $p$ = 0.1 to $p$ = 0.9 with a step of 0.05 and generating random values until the trial turns to be a success, keeping the count of the trials in mind.\
  84. The Octave code for part (c) is as follows:
  85.  
  86. \begin{lstlisting}
  87. X = [];
  88. for p = 0.1:0.05:0.9
  89.   number = rand; % Generate continuous uniform number bet. 0 & 1.
  90.   trials = 1;
  91.   while(number >= p)
  92.     trials = trials + 1;
  93.     number = rand;
  94.   end
  95.   X = [X trials];
  96. end
  97. p = [0.1:0.05:0.9];
  98. plot(p, X, 'LineWidth', 1.5);
  99. xlabel("p: the probability of success");
  100. ylabel("X: the number of trials");
  101. \end{lstlisting}
  102.  
  103. \begin{figure}[H]
  104. \centering
  105. \includegraphics[width=450px]{prob1c}
  106. \caption{Number of trials versus the probability of success p - part (c)}
  107. \end{figure}
  108.  
  109. \item Running the above program 10 times we get the following curve:
  110.  
  111. \begin{figure}[H]
  112. \centering
  113. \includegraphics[width=450px]{prob1d}
  114. \caption{Plotting 10 curves of the number of trials - part (d)}
  115. \end{figure}
  116.  
  117. \begin{lstlisting}
  118. hold on;
  119. p_domain = [0.1:0.05:0.9];
  120. for i = 1:10
  121.   X = [];
  122.   for p = 0.1:0.05:0.9
  123.     number = rand; % Generate continuous uniform number bet. 0 & 1.
  124.     trials = 1;
  125.     while(number >= p)
  126.       trials = trials + 1;
  127.       number = rand;
  128.     end
  129.     X = [X trials];
  130.   end
  131.   plot(p_domain, X, 'LineWidth', 1.5);
  132. end
  133. xlabel("p: the probability of success");
  134. ylabel("X: the number of trials");
  135. hold off;
  136. \end{lstlisting}
  137.  
  138. \item The curve in (d) contains multiple random experiments, some are a good fit to the curve in (a) and some are not, this is due to the randomness used to generate the curve, if we increase the number of iteratrions in curve (d), it will approach the curve in (a) more and more.
  139.  
  140. \textbf{[III] One message:} \item The expected number of trials of 800 packets in sequence is 800 times the expected number of trials of one packet. $E[X] = n \cdot 1/p = 800/p$.
  141.  
  142. \begin{figure}[H]
  143. \centering
  144. \includegraphics[width=450px]{prob1f}
  145. \caption{The expected number of trials to send 800 packets - part (f)}
  146. \end{figure}
  147.  
  148. The Octave code for the plot above:
  149.  
  150. \begin{lstlisting}
  151. p = [0:0.007:1];
  152. plot(p, 800./p, 'LineWidth', 1.5);
  153. xlabel("p: the probability of success of a trial");
  154. ylabel("E[X]: the expected number of trials");
  155. title("Expected number of trials to successfully send 800 packets");
  156. \end{lstlisting}
  157.  
  158. \pagebreak
  159.  
  160. \item The MATLAB code in this part is similar to part (c) except that we need to iterate 800 times for each $p$.
  161.  
  162. \begin{lstlisting}
  163. X = [];
  164. for p = 0.1:0.05:0.9
  165.   trials = 1;
  166.   for i = 1:800
  167.     number = rand; % Generate continuous uniform number bet. 0 & 1.
  168.     while(number >= p)
  169.       trials = trials + 1;
  170.       number = rand;
  171.     end
  172.   end
  173.   X = [X trials];
  174. end
  175.  
  176. p = [0.1:0.05:0.9];
  177. plot(p, X, 'LineWidth', 1.5);
  178. xlabel("p: the probability of success");
  179. ylabel("X: the number of trials");
  180.  
  181. \end{lstlisting}
  182.  
  183. \begin{figure}[H]
  184. \centering
  185. \includegraphics[width=450px]{prob1g}
  186. \caption{The number of trials - part (g)}
  187. \end{figure}
  188.  
  189. \pagebreak
  190. \textbf{[IV] Computer Network:} We can calculate the probability that a packet is delivered over the network by subtracting the probability of failure of the network from 1, to get the probability of failure of the network we need all 3 networks R1, R2, and R3 to fail delivering the packet altogether.
  191. \begin{align*}
  192. P_{\text{delivering the message}} &= 1 - P_{\text{failure to deliver the message}}\\
  193. &= 1 - (R1' \cap R2' \cap R3')\\
  194. & = 1 - (1-p)^2 \cdot (1-p)^2 \cdot (1-p)^2 \\
  195. &= 1 - (1-p)^6
  196. \end{align*}
  197.  
  198. \item We can model the transmission of a message as a Geometric Random Variable with probability of success $p'$ = $P_{\text{delivering the message}}$ calculated above, therefore the expected number of trials of this Geometric Random Variable $E[X]$ can be calculated as follows: $E[X] = 1/p'$.
  199.  
  200. \begin{figure}[H]
  201. \centering
  202. \includegraphics[width=450px]{prob1h}
  203. \caption{The expected number of trials of sending the message over the network - part (h)}
  204. \end{figure}
  205.  
  206. \pagebreak
  207.  
  208. The code for the plot above:
  209. \begin{lstlisting}
  210. p = [0.01:0.0001:1];
  211. P = 1 - (1-p).^6;
  212. plot(p, 1./P, 'LineWidth', 1.5);
  213. xlabel("p: the probability of success of a trial");
  214. ylabel("E[X]: the expected number of trials");
  215. title("Expected number of trials to successfully send a message");
  216. \end{lstlisting}
  217.  
  218. \item We can plot the two curves over each other to get a clear view of when any case is better than the other, plotting them together we get:
  219. \end{enumerate}
  220.  
  221. \begin{figure}[H]
  222. \centering
  223. \includegraphics[width=400px]{prob1i}
  224. \caption{Plotting One Packet curve over Computer Network - part (i)}
  225. \end{figure}
  226.  
  227. \begin{lstlisting}
  228. hold on;
  229. p = [0.01:0.0001:1];
  230. P = 1 - (1-p).^6;
  231. plot(p, 1./p, 'LineWidth', 1.5);
  232. plot(p, 1./P, 'LineWidth', 1.5);
  233. xlabel("p: the probability of success of a trial");
  234. ylabel("E[X]: the expected number of trials");
  235. title("Expected number of trials to successfully send a packet");
  236. legend("One Packet", "Computer Network");
  237. hold off;
  238. \end{lstlisting}
  239.  
  240. We immediately notice that the \textit{Computer Network} number of expectations curve is a lower bound to \textit{One Packet} which infers that transferring a message over the \textit{Computer Network} will \textbf{always} be better than transferring it on \textit{One Packet}.
  241.  
  242. \textbf{\underline{Question 2}}
  243. \begin{enumerate}
  244. \item Since $f(x)$ is a valid pdf, integrating it over the whole domain should be equal to 1, we can calculate the integration of $f(x)$ and equate it to 1 to find the value of $k$.
  245.  
  246. $$\int_{-\infty}^{\infty} f(x) dx = 1$$
  247. $$\int_{-3}^{3} k(16.5-x^2) dx = 1$$
  248. $$k \cdot (16.5x - \frac{x^3}{3})\Bigg|_{-3}^{3} = 1$$
  249. $$k \cdot (16.5(3) - \frac{(3)^3}{3} - 16.5(-3) + \frac{(-3)^3}{3}) = 1$$
  250. $$k \cdot 81 = 1$$
  251. \begin{center}
  252. \boxed{k = \frac{1}{81}}
  253. \end{center}
  254. \item We can find $P(X < 1.5)$ by integrating the pdf from the lowest limit to 1.5:
  255. \begin{align*}
  256. P(X < 1.5) &= \int_{-\infty}^{1.5} f(x) dx\\
  257. &= \int_{-3}^{1.5} \frac{1}{81}(16.5-x^2) dx\\
  258. &= \frac{1}{81} \cdot (16.5x - \frac{x^3}{3})\Bigg|_{-3}^{1.5}\\
  259. & = \frac{1}{81} \cdot (16.5(1.5) - \frac{(1.5)^3}{3} - 16.5(-3) + \frac{(-3)^3}{3})
  260. \end{align*}
  261. \begin{center}
  262. \boxed{P(X < 1.5) = \frac{19}{24} = 0.7916667}
  263. \end{center}
  264. \pagebreak
  265. \item We can find $P(|X| > 2.4)$ by expanding the absolute value and therefore calculating $P(X < -2.4 \cap X > 2.4)$ instead which is equal to calculating $1 - P(-2.4 < X < 2.4)$ which can be easily calculated directly from the pdf.
  266. \begin{align*}
  267. P(|X| > 2.4) &= P(X < -2.4 \cap X > 2.4) = 1 - P(-2.4 < X < 2.4)\\
  268. &= 1 - \int_{-2.4}^{2.4} f(x) dx\\
  269. &= 1 - \int_{-2.4}^{2.4} \frac{1}{81}(16.5-x^2) dx\\
  270. &= 1 - \frac{1}{81} \cdot (16.5x - \frac{x^3}{3})\Bigg|_{-2.4}^{2.4}\\
  271. &= 1 - \frac{1}{81} \cdot (16.5(2.4) - \frac{(2.4)^3}{3} - 16.5(-2.4) + \frac{(-2.4)^3}{3})
  272. \end{align*}
  273. \begin{center}
  274. \boxed{P(|X| > 2.4) = 0.136}
  275. \end{center}
  276. \end{enumerate}
  277. \textbf{\underline{Question 3}}
  278. \begin{enumerate}
  279. \item The total number of people with university education = 22 + 17 = 39\\
  280.    $P(\text{the person has university education}) = \frac{39}{200} = 0.195$\
  281.    
  282. \item The total number of males with secondary education = 28\\
  283.    $P(\text{the person is a male with secondary education}) = \frac{28}{200} = 0.14$\
  284.    
  285. \item The total number of people with secondary education = 78\\
  286.    $P(\text{the person is a male} \vert \text{the person has a secondary education}) = \frac{28}{78} = 0.3589$\
  287.    
  288.    We can also calculate it by using the property $P(A | B) = P(A \cap B)/P(B) $\\
  289.    $P(\text{the person is a male} \vert \text{the person has a secondary education}) = P(\text{the person is a male} \cap \text{the person has a secondary education}) / P(\text{the person has a secondary education}) =  \frac{28}{200} / \frac{78}{200} = 28/78 = 0.3589$\
  290. \item The total number of females = 112 and the total number of females without university degree = 95\\
  291.    $P(\text{the person does not have a university degree} \vert \text{the person is a female}) = \frac{95}{112} = 0.848214$\
  292.    We can also calculate it by using the property $P(A | B) = P(A \cap B)/P(B) $\\
  293.    $P(\text{the person does not have a university degree} \vert \text{the person is a female}) = \frac{95}{200} / \frac{112}{200} = 95/112 = 0.848214$\
  294. \item We can approach this by trying to prove that they are independent, and if they fail to be, then they are dependent.\
  295. \end{enumerate}
  296. \pagebreak
  297. \textbf{\underline{Question 4}}
  298. \begin{enumerate}
  299. \item Since $X$ follows the distribution $U(0,1)$ then:
  300. $$E(X) = \frac{1+0}{2} = 0.5 ~ \text{and} ~ Var(X) = \frac{(1-0)^2}{12} = \frac{1}{12} = 0.0833$$
  301. \item Using $E[aX+b] = a \cdot E[X] + b$ (linearity) we can get:
  302. $$E[2X + 3] = 2 \cdot E[X] + 3 = 2 \cdot 0.5 + 3 = 4$$
  303. and using $Var(aX+b) = a^2 \cdot Var(X)$ we get:
  304. $$Var(2X+3) = 2^2 \cdot Var(X) = 4 \cdot \frac{1}{12} = 0.3333$$
  305. \item Using $P(A~|~B) = P(A \cap B) / P(B)$:
  306. \begin{align*}
  307. P(X > 0.2~|~X \leq 0.5) &= P(X > 0.2 \cap X \leq 0.5) / P( X \leq 0.5)\\
  308. &= \ddfrac{\frac{0.5-0.2}{1.0 - 0}}{\frac{0.5 - 0}{1.0 - 0}}\\
  309. &= \frac{0.5-0.2}{0.5 - 0}
  310. \end{align*}
  311. \begin{center}
  312. \boxed{P(X > 0.2~|~X \leq 0.5) = 0.6}
  313. \end{center}
  314. \end{enumerate}
  315. \pagebreak
  316. \textbf{\underline{Question 5}}\
  317. \begin{enumerate}
  318. \item We can use the definition to find the marginal densities
  319. \begin{align*}
  320. f(x) &= \int_{-\infty}^{\infty} f(x,y) dy\\
  321. &= \int_{0}^{1} \frac{3x-y}{4} dy\\
  322. &= \frac{1}{4} \cdot (3xy - \frac{y^2}{2}) \Bigg|_{0}^{1}\\
  323. &= \frac{1}{4} \cdot (3x - \frac{1}{2})
  324. \end{align*}
  325. \begin{center}
  326. \boxed{f(x) = \frac{3x}{4} - \frac{1}{8}}
  327. \end{center}
  328. and
  329. \begin{align*}
  330. f(y) &= \int_{-\infty}^{\infty} f(x,y) dx\\
  331. &= \int_{1}^{2} \frac{3x-y}{4} dx\\
  332. &= \frac{1}{4} \cdot (\frac{3x^2}{2} - xy) \Bigg|_{1}^{2}\\
  333. &= \frac{1}{4} \cdot (\frac{3(4)}{2} - 2y - \frac{3}{2} + y)\\
  334. &= \frac{1}{4} \cdot (\frac{9}{2} - y )
  335. \end{align*}
  336. \begin{center}
  337. \boxed{f(y) = \frac{9}{8} - \frac{y}{4}}
  338. \end{center}
  339. \pagebreak
  340. \item Using $P( a < Y < b~|~ X = x) =  \int_{a}^{b} f(y|x) dy$ and $f(y|x) = \dfrac{f(x,y)}{f_{X}(x)}$
  341. We need to find $f(y|x)$ first:
  342. \begin{align*}
  343. f(y|x) &= \dfrac{f(x,y)}{f_{X}(x)}\\
  344. &= \dfrac{(3x-y)/4}{(3x-\frac{1}{2})/4}\Bigg|_{x = \frac{4}{3}}\\
  345. &= \dfrac{3\frac{4}{3}-y}{3\frac{4}{3}-\frac{1}{2}}\\
  346. &= \dfrac{4-y}{4-\frac{1}{2}}\\
  347. &= \dfrac{4-y}{7/2}\\
  348. &= \dfrac{8-2y}{7}
  349. \end{align*}
  350. Now we can integrate $f(y|x)$ over the interval of $y$ to find $P(Y < 1/2~|~ X = 4/3)$
  351. \begin{align*}
  352. P(Y < 1/2~|~ X = 4/3) &= \int_{0}^{1/2} f(y|x) dy\\
  353. &= \int_{0}^{1/2} \dfrac{8-2y}{7} dy\\
  354. &= \frac{1}{7} \cdot (8y-y^2)\Bigg|_{y = 0}^{y = 1/2}\\
  355. &= \frac{1}{7} \cdot (8 \cdot \frac{1}{2}-(\frac{1}{2})^2)
  356. \end{align*}
  357. \begin{center}
  358. \boxed{P(Y < 1/2~|~ X = 4/3) = 0.5357}
  359. \end{center}
  360. \item We can find $P(Y < 1/2~|~X < 4/3)$ by integrating the joint probability density function $f(x,y)$
  361. $$P(Y < 1/2~|~X < 4/3) = \frac{\int_{0}^{1/2} \int_{1}^{4/3} f(x,y) \,dx\,dy}{\int_{1}^{4/3} f_{X}(x) dx}$$
  362. \pagebreak
  363. Evaluating $\int_{0}^{1/2} \int_{1}^{4/3} f(x,y) \,dx\,dy$:
  364. \begin{align*}
  365. \int_{0}^{1/2} \int_{1}^{4/3} f(x,y) \,dx\,dy &= \int_{0}^{1/2} \int_{1}^{4/3} (3x-y)/4 \,dx\,dy\\
  366. & = \frac{1}{4} \int_{0}^{1/2} (\frac{3x^2}{2}-xy)\Bigg|_{x = 1}^{x = 4/3}\,dy\\
  367. & = \frac{1}{4} \int_{0}^{1/2} (\frac{3(4/3)^2}{2}-\frac{4y}{3} - \frac{3(1)^2}{2} + y)\,dy\\
  368. & = \frac{1}{4} \int_{0}^{1/2} (\frac{7}{6}-\frac{y}{3})\,dy\\
  369. & = \frac{1}{4} (\frac{7y}{6}-\frac{y^2}{6}) \Bigg|_{y = 0}^{y = 1/2}\\
  370. & = \frac{1}{4} (\frac{7(1/2)}{6}-\frac{(1/2)^2}{6}) \Bigg|_{y = 0}^{y = 1/2}\\
  371. & = \frac{1}{4} (\frac{7(1/2)}{6}-\frac{(1/2)^2}{6})
  372. \end{align*}
  373. \begin{center}
  374. \boxed{\int_{0}^{1/2} \int_{1}^{4/3} f(x,y) \,dx\,dy = \frac{13}{96}}
  375. \end{center}
  376. Evaluating $\int_{1}^{4/3} f_{X}(x) dx$:
  377. \begin{align*}
  378. \int_{1}^{4/3} f_{X}(x) dx &= \int_{1}^{4/3} \frac{1}{4} \cdot (3x - \frac{1}{2}) dx\\
  379. & = \frac{1}{4} \cdot (\frac{3x^2}{2} - \frac{x}{2}) \Bigg|_{x = 1}^{x = 4/3}\\
  380. & = \frac{1}{4} \cdot (\frac{3(4/3)^2}{2} - \frac{(4/3)}{2} - \frac{3(1)^2}{2} + \frac{1}{2})
  381. \end{align*}
  382. \begin{center}
  383. \boxed{\int_{1}^{4/3} f_{X}(x) dx = \frac{1}{4}}
  384. \end{center}
  385. Now we can finally evaluate $P(Y < 1/2~|~X < 4/3)$ by dividing both expressions by each other as follows:
  386. $$P(Y < 1/2~|~X < 4/3) = \frac{13/96}{1/4}$$
  387. \begin{center}
  388. \boxed{P(Y < 1/2~|~X < 4/3) = \frac{13}{24} = 0.5416667}
  389. \end{center}
  390. \item They are \textbf{dependent} as the conditional probability of $Y$ given $X$ has different values as the condition on $X$ changes, i.e. The result in (b) is different from the result in (c) although they have the same domain on $Y$ but different domains on $X$, therefore they are dependent.
  391. \end{enumerate}
  392. \textbf{\underline{Question 6}}\
  393. \begin{enumerate}
  394. \item The general idea of linear regression is that we have some input data that are not necessarily linear, and we try to fit a straight line through those points in a way as to minimize the mean squared error (MSE) between the points and the straight line, this helps us to fit a model into our data that will make us able to predict future values according to the past input data. Linear Regression is used in many applications, and it is a concrete building block in machine learning as fitting a model on existing data is key to predicting future values accurately. Linear Regression is also the simplest method of fitting data as the relationship between the features and values is linear.\
  395. Since minimizing the mean square error is an important point in linear regression, we need to derive the formula of the least squares coefficients:\
  396. We are trying to fit a straight line of the form $y = b_0 + b_1 x$ on our data, therefore, our unknowns are $b_0$ and $b_1$, we need to find values for them such that the sum of the squares of the residuals is minimum. The residual sum of squares is often called the sum of squares of the errors about the regression line and is denoted by SSE. This minimization procedure for estimating the parameters is called the method of least squares. Hence, we shall find a and b so as to minimize:
  397. $$SSE = \sum_{i=1}^{n} e_i^2 = \sum_{i=1}^{n}(y_i - \hat y_i)^2 = \sum_{i=1}^{n}(y_i - b_0 -b_1 x_i)^2$$
  398. Differentiating SSE with respect to b0 and b1, we have
  399. $$\frac{\partial(SSE)}{\partial b_0} = -2\sum_{i=1}^{n} (y_i - b_0 -b_1 x_i), ~~ \frac{\partial(SSE)}{\partial b_1} = -2\sum_{i=1}^{n} (y_i - b_0 -b_1 x_i) x_i $$
  400. Setting the partial derivatives equal to zero and rearranging the terms, we obtain the equations (called the \textbf{normal equations}).
  401. $$nb_0 + b_1 \sum_{i=1}^{n} x_i = \sum_{i=1}^{n} y_i, ~~ b_0 \sum_{i=1}^{n} x_i + b_1 \sum_{i=1}^{n} x_i^2 = \sum_{i=1}^{n} x_i y_i$$
  402. which may be solved simultaneously to yield computing formulas for b0 and b1.\\
  403. Given the sample $\{(x_i,y_i); i =1 ,2,...,n\}$, the least squares estimates $b_0$ and $b_1$ are computed from the formulas
  404. $$b_1 = \frac{n \sum_{i=1}^{n}x_i y_i - (\sum_{i=1}^{n}x_i) (\sum_{i=1}^{n} y_i)}{n\sum_{i=1}^{n}x_i^2 - (\sum_{i=1}^{n}x)^2} = \frac{\sum_{i=1}^{n}(x_i - \bar x)(y_i - \bar y)}{\sum_{i=1}^{n} (x_i - \bar x)^2}$$ and
  405. $$b_0 = \frac{\sum_{i=1}^{n}y_i - b_1 \sum_{i=1}^{n} x_i}{n} = \bar y - b_1 \bar x$$
  406. \item Applying the expressions to find the coefficients we can find the best fit line as shown in the plot
  407. \begin{figure}[H]
  408. \centering
  409. \includegraphics[width=400px]{prob6b}
  410. \caption{The best fit to the data in question 6}
  411. \end{figure}
  412. \end{enumerate}
  413. \textbf{\underline{Question 7}}\
  414. \begin{enumerate}
  415. \item We know that $P(\bar X - t_{\alpha/2} \frac{S}{\sqrt{n}} < \mu < \bar X + t_{\alpha/2} \frac{S}{\sqrt{n}}) = 1 - \alpha$, so we need to find $S$ then find $t_{\alpha/2}$.\\
  416. Finding $\bar X$ using $\sum_{i=1}^{n} X_i$, where $n = 7$:
  417. $$\bar X = \frac{1}{7} \cdot (620.38 + 558.49 + 657.09 + 636.86 + 680.27 + 666.82 + 662.04)$$
  418. \begin{center}
  419. \boxed{\bar X = 640.2785}
  420. \end{center}
  421. Finding $S$ using $S^2 = \frac{1}{n-1} \sum_{i=1}^{n} (X_i - \bar X)^2$ where $n = 7$:
  422. \begin{center}
  423. \boxed{S = 41.14396}
  424. \end{center}
  425. Since the confidence interval is 99\%, $\alpha/2$ will be 0.5\%, using the critical values t-distribution table to find $t_{0.5\%}$ by searching for the value where the pdf is equal to $1-0.5\% = 0.995$ and $v = n-1 = 6$ we get $t_{0.5\%} = 3.707$.
  426. Substituting in the formula stated above:
  427. $$640.2785 - 3.707 \frac{41.14396}{\sqrt{7}} < \mu < 640.2785 + 3.707 \frac{41.14396}{\sqrt{7}}$$
  428. \begin{center}
  429. \boxed{582.6311 < \mu < 697.9258}
  430. \end{center}
  431. \item Knowing that $\sigma = 35$ we can directly use the standard normal distribution curve and using the interval function $P(\bar X - Z_{\alpha/2} \frac{\sigma}{\sqrt{n}} < \mu < \bar X + Z_{\alpha/2} \frac{\sigma}{\sqrt{n}}) = 1 - \alpha$
  432. Since the confidence interval is 99\%, $\alpha/2$ will be 0.5\%, using the standard normal distribution table to find $Z_{0.5\%}$ by searching for the value where the pdf is equal to $1-0.5\% = 0.995$ and we get:
  433. \begin{center}
  434. \boxed{Z_{0.5\%} = 2.575}\
  435. (there were two values but it is reasonable to choose their mean)
  436. \end{center}
  437. Substituting in the formula stated above:
  438. $$640.2785 - 2.575 \frac{35}{\sqrt{7}} < \mu < 640.2785 + 2.575 \frac{35}{\sqrt{7}}$$
  439. \begin{center}
  440. \boxed{606.2144 < \mu < 674.3425}
  441. \end{center}
  442. \end{enumerate}
  443. \begin{thebibliography}{00}
  444. \bibitem{reference}
  445. Myers, Myers, Walpole, and Ye (2012), Probability and Statistics for Engineers and Scientists ($9^{th}$ ed).
  446.  
  447. \end{thebibliography}
  448.  
  449. \end{document}
Add Comment
Please, Sign In to add comment