class: center, middle, inverse, title-slide # Continuous Uniform Distribution ### Dr. Dogucu --- layout: true <div class="my-header"></div> <div class="my-footer"> Copyright © <a href="https://mdogucu.ics.uci.edu">Dr. Mine Dogucu</a>. <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a></div> --- ## pdf `\(X \sim \mathcal{U}(a,b)\)` .pull-left[ <img src="img/uniform_pdf.png" width="90%" style="display: block; margin: auto;" /> ] .pull-right[ <img src="slide-3-uniform_files/figure-html/unnamed-chunk-2-1.png" style="display: block; margin: auto;" /> ] --- ## Expected Value `\(E(X) = \int_{x \ \epsilon \ S_X} xf(x)dx\)` -- `\(E(X) = \int_a^b x\frac{1}{b-a}dx\)` -- `\(E(X) = \frac{1}{b-a} \big[\frac{x^2}{2}\bigg\rvert_a^b\big]\)` -- `\(E(X) = \frac{1}{b-a} \big[\frac{b^2}{2} - \frac{a^2}{2}\big]\)` -- `\(E(X) = \frac{b^2 - a^2}{2(b-a)}\)` -- `\(E(X) = \frac{b+a}{2}\)` --- ## `\(E(X^2)\)` `\(Var(X) = E(X^2)- [E(X)]^2\)` -- `\(E(X^2) = ?\)` -- `\(E(X^2) = \int_a^b x^2\frac{1}{b-a}dx\)` -- `\(E(X^2) = \frac{1}{b-a} \big[\frac{x^3}{3}\bigg\rvert_a^b\big]\)` -- `\(E(X^2) = \frac{b^3 - a^3}{3(b-a)}\)` --- ## Variance `\(Var(X) = E(X^2)- [E(X)]^2\)` -- `\(Var(X) = \frac{b^3 - a^3}{3(b-a)}- (\frac{b+a}{2})^2\)` -- `\(Var(X) = \frac{(b-a) (b^2+ab+a^2)}{3(b-a)}- \frac{(b+a)^2}{4}\)` -- `\(Var(X) = \frac{(b-a)^2}{12}\)` --- ## Example A cellphone has a defective alarm system. Once every day the alarm starts ringing randomly. Let X be the random variable representing the time in the 24 hour system when the alarm goes on. -- .pull-right[ <img src="slide-3-uniform_files/figure-html/unnamed-chunk-3-1.png" style="display: block; margin: auto;" /> ] -- `\(f(x) = \frac{1}{b-a} \text{ for } \ a \leq x \leq b\)` `\(f(x) = \frac{1}{24-0} \text{ for } x \ \epsilon [0,24)\)` --- ## pdf .pull-right[ <img src="slide-3-uniform_files/figure-html/unnamed-chunk-4-1.png" style="display: block; margin: auto;" /> ] .pull-left[ ```r dunif(x = 3, min = 0, max = 24) ``` ``` ## [1] 0.04166667 ``` ] -- .pull-left[ ```r dunif(x = 15, min = 0, max = 24) ``` ``` ## [1] 0.04166667 ``` ] -- .pull-left[ ```r dunif(x = 21.25, min = 0, max = 24) ``` ``` ## [1] 0.04166667 ``` ] --- ## Calculating Probability What is the probability that the phone alarm will ring at 3 am? -- .pull-right[ <img src="slide-3-uniform_files/figure-html/unnamed-chunk-8-1.png" style="display: block; margin: auto;" /> ] -- `\(P(X = 3) = 0\)` `\(\int_3^{3}\frac{1}{b-a}dx = 0\)` -- --- ## Calculating Probability What is the probability that the phone alarm will ring at some time between midnight and 8 am? -- .pull-right[ <img src="slide-3-uniform_files/figure-html/unnamed-chunk-9-1.png" style="display: block; margin: auto;" /> ] Cumulative probability! -- `\(\int_0^{8}\frac{1}{b-a}dx\)` -- `\(\frac{x}{b-a}\bigg\rvert_0^8 = \frac{8}{24} = \frac{1}{3}\)` -- ```r punif(q = 8, min = 0, max = 24) ``` ``` ## [1] 0.3333333 ``` --- ## Calculating Probability What is the probability that the phone alarm will ring at some time between 2 am to 8 am? -- .pull-right[ <img src="slide-3-uniform_files/figure-html/unnamed-chunk-11-1.png" style="display: block; margin: auto;" /> ] `\(P(2<X<8) = ?\)` -- `\(\frac{x}{b-a}\bigg\rvert_2^8 = \frac{8}{24} - \frac{2}{24}= \frac{1}{4}\)` -- `\(P(X<8) - P(X<2)\)` -- ```r punif(q = 8, min = 0, max = 24) - punif(q = 2, min = 0, max = 24) ``` ``` ## [1] 0.25 ``` --- ## Expected Value What is the expected value of the time that the phone alarm will go on? -- `\(E(X) = \frac{b+a}{2}\)` -- `\(E(X) = \frac{24+0}{2}\)` -- `\(E(X) = 12\)` -- We found that the expected value is 12. Does that mean that every day we would expect the alarm to go on at noon (12 pm)? -- No! Some days the alarm might go on at 9 am, some days at 3 pm (15). Some days it might go on at 9:15 pm (21.25). We would expect the average to be 12 in the long run. --- ## Variance We already pointed out that there is variance to the time the alarm goes on. It is not at noon every day. What is the variance of the time that the phone alarm will go on? -- `\(Var(X) = \frac{(b-a)^2}{12}\)` -- `\(Var(X) = \frac{(24-0)^2}{12}\)` -- `\(Var(X) = 48\)`