Skip to content

Commit

Permalink
Added hw2
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaffo committed May 18, 2014
1 parent 52ea2fa commit 4b9e4c6
Show file tree
Hide file tree
Showing 3 changed files with 455 additions and 8 deletions.
107 changes: 105 additions & 2 deletions 06_StatisticalInference/homework/hw2.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ Suppose that the number of web hits to a particular site are approximately norma
distributed with a mean of 100 hits per day and a standard deviation of 10 hits per day. What's the probability that a given day has fewer than 93 hits per day
expressed as a percentage to the nearest percentage point?

1. 76%
2. _24%_
3. 47%
4. 94%

*** .hint
Let $X$ be the number of hits per day. We want $P(X \leq 93)$ given that
$X$ is $N(100, 10^2)$.
Expand Down Expand Up @@ -104,6 +109,7 @@ Suppose that the number of web hits to a particular site are approximately norma
distributed with a mean of 100 hits per day and a standard deviation of 10 hits per day. What number of web hits per day represents the number so that only
5% of days have more hits? Express your answer to 3 decimal places.


*** .hint
Let $X$ be the number of hits per day. We want $P(X \leq 93)$ given that
$X$ is $N(100, 10^2)$.
Expand All @@ -115,9 +121,11 @@ round(qnorm(.05, mean = 100, sd = 10, lower.tail = FALSE), 3)
```


--- &radio
--- &multitext
Suppose that the number of web hits to a particular site are approximately normally
distributed with a mean of 100 hits per day and a standard deviation of 10 hits per day. Imagine taking a random sample of 50 days. What number of web hits would
distributed with a mean of 100 hits per day and a standard deviation of 10 hits per day. Imagine taking a random sample of 50 days.

1. What number of web hits would
be the point so that only 5% of averages of 50 days of web traffic have more hits?
Express your answer to 3 decimal places.

Expand All @@ -126,8 +134,103 @@ Let $\bar X$ be the average number of hits per day for 50 randomly sampled days.
$X$ is $N(100, 10^2 / 50)$.

*** .explanation
<span class="answer">`r round(qnorm(.95, mean = 100, sd = 10 / sqrt(50) ), 3)`</span>

```{r}
round(qnorm(.95, mean = 100, sd = 10 / sqrt(50) ), 3)
round(qnorm(.05, mean = 100, sd = 10 / sqrt(50), lower.tail = FALSE), 3)
```

--- &multitext

You don't believe that your friend can discern good wine from cheap. Assuming
that you're right, in a blind test where you randomize 6 paired varieties (Merlot,
Chianti, ...) of cheap and expensive wines

1. what is the change that she gets 5 or 6 right expressed as a percentage
to one decimal place?

*** .hint
Let $p=.5$ and $X$ be binomial

*** .explanation

<span class="answer">`r round(pbinom(4, prob = .5, size = 6, lower.tail = TRUE) * 100, 1)`</span>

```{r}
round(pbinom(4, prob = .5, size = 6, lower.tail = TRUE) * 100, 1)
```

--- &multitext

Consider a uniform distribution. If we were to sample 100 draws from a
a uniform distribution (which has mean 0.5, and variance 1/12) and take their
mean, $\bar X$

1. what is the approximate probability of getting as large as 0.51 or larger expressed to 3 decimal places?

*** .hint
Use the central limit theorem that says $\bar X \sim N(\mu, \sigma^2/n)$

*** .explanation

<span class="answer"> `r round(pnorm(.51, mean = 0.5, sd = sqrt(1 / 12 / 100), lower.tail = FALSE), 3)`</span>

```{r}
round(pnorm(.51, mean = 0.5, sd = sqrt(1 / 12 / 100), lower.tail = FALSE), 3)
```


--- &multitext

If you roll ten standard dice, take their average, then repeat this process over and over and construct a histogram,

1. what would it be centered at?


*** .hint
$E[X_i] = E[\bar X]$ where $\bar X = \frac{1}{n}\sum_{i=1}^n X_i$

*** .explanation


The answer will be <span class="answer">3.5</span> since the mean of the
sampling distribution of iid draws will be the population mean that the
individual draws were taken from.

--- &multitext

If you roll ten standard dice, take their average, then repeat this process over and over and construct a histogram,

1. what would be its variance expressed to 3 decimal places?

*** .hint
$$Var(\bar X) = \sigma^2 /n$$

*** .explanation
The answer will be <span class="answer">`r round( mean(1 : 6 - 3.5) ^2 / 100, 3)`</span>
since the variance of the sampling distribution of the mean is $\sigma^2/12$
and the variance of a die roll is

```{r}
mean((1 : 6 - 3.5)^2)
```

--- &multitext
The number of web hits to a site is Poisson with mean 16.5 per day.

1. What is the probability of getting 20 or fewer in 2 days expressed
as a percentage to one decimal place?

*** .hint
Let $X$ be the number of hits in 2 days then $X \sim Poisson(2\lambda)$

*** .explanation
<span class="answer">`r round(ppois(20, lambda = 16.5 * 2) * 100, 1)`</span>

```{r}
round(ppois(20, lambda = 16.5 * 2) * 100, 1)
```



225 changes: 221 additions & 4 deletions 06_StatisticalInference/homework/hw2.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ <h2>About these slides</h2>
distributed with a mean of 100 hits per day and a standard deviation of 10 hits per day. What&#39;s the probability that a given day has fewer than 93 hits per day
expressed as a percentage to the nearest percentage point?</p>

<ol>
<li>76%</li>
<li><em>24%</em></li>
<li>47%</li>
<li>94%</li>
</ol>

<button class="quiz-submit btn btn-primary">Submit</button>
<button class="quiz-toggle-hint btn btn-info">Show Hint</button>
<button class="quiz-show-answer btn btn-success">Show Answer</button>
Expand Down Expand Up @@ -211,11 +218,15 @@ <h2>About these slides</h2>
<slide class="" id="slide-6" style="background:;">
<article data-timings="">

<div class="quiz quiz-single well ">
<div class="quiz-text quiz-multitext well">
<p>Suppose that the number of web hits to a particular site are approximately normally
distributed with a mean of 100 hits per day and a standard deviation of 10 hits per day. Imagine taking a random sample of 50 days. What number of web hits would
distributed with a mean of 100 hits per day and a standard deviation of 10 hits per day. Imagine taking a random sample of 50 days. </p>

<ol>
<li>What number of web hits would
be the point so that only 5% of averages of 50 days of web traffic have more hits?
Express your answer to 3 decimal places. </p>
Express your answer to 3 decimal places. </li>
</ol>

<button class="quiz-submit btn btn-primary">Submit</button>
<button class="quiz-toggle-hint btn btn-info">Show Hint</button>
Expand All @@ -228,7 +239,9 @@ <h2>About these slides</h2>

</div>
<div class="quiz-explanation">
<pre><code class="r">round(qnorm(.95, mean = 100, sd = 10 / sqrt(50) ), 3)
<p><span class="answer">102.326</span></p>

<pre><code class="r">round(qnorm(.95, mean = 100, sd = 10 / sqrt(50) ), 3)
</code></pre>

<pre><code>[1] 102.3
Expand All @@ -240,6 +253,180 @@ <h2>About these slides</h2>
<pre><code>[1] 102.3
</code></pre>

</div>
</div>
</article>
<!-- Presenter Notes -->
</slide>

<slide class="" id="slide-7" style="background:;">
<article data-timings="">

<div class="quiz-text quiz-multitext well">
<p>You don&#39;t believe that your friend can discern good wine from cheap. Assuming
that you&#39;re right, in a blind test where you randomize 6 paired varieties (Merlot,
Chianti, ...) of cheap and expensive wines</p>

<ol>
<li>what is the change that she gets 5 or 6 right expressed as a percentage
to one decimal place?</li>
</ol>

<button class="quiz-submit btn btn-primary">Submit</button>
<button class="quiz-toggle-hint btn btn-info">Show Hint</button>
<button class="quiz-show-answer btn btn-success">Show Answer</button>
<button class="quiz-clear btn btn-danger">Clear</button>

<div class="quiz-hint">
<p>Let \(p=.5\) and \(X\) be binomial</p>

</div>
<div class="quiz-explanation">
<p><span class="answer">89.1</span></p>

<pre><code class="r">round(pbinom(4, prob = .5, size = 6, lower.tail = TRUE) * 100, 1)
</code></pre>

<pre><code>[1] 89.1
</code></pre>

</div>
</div>
</article>
<!-- Presenter Notes -->
</slide>

<slide class="" id="slide-8" style="background:;">
<article data-timings="">

<div class="quiz-text quiz-multitext well">
<p>Consider a uniform distribution. If we were to sample 100 draws from a
a uniform distribution (which has mean 0.5, and variance 1/12) and take their
mean, \(\bar X\)</p>

<ol>
<li>what is the approximate probability of getting as large as 0.51 or larger expressed to 3 decimal places?</li>
</ol>

<button class="quiz-submit btn btn-primary">Submit</button>
<button class="quiz-toggle-hint btn btn-info">Show Hint</button>
<button class="quiz-show-answer btn btn-success">Show Answer</button>
<button class="quiz-clear btn btn-danger">Clear</button>

<div class="quiz-hint">
<p>Use the central limit theorem that says \(\bar X \sim N(\mu, \sigma^2/n)\)</p>

</div>
<div class="quiz-explanation">
<p><span class="answer"> 0.365</span></p>

<pre><code class="r">round(pnorm(.51, mean = 0.5, sd = sqrt(1 / 12 / 100), lower.tail = FALSE), 3)
</code></pre>

<pre><code>[1] 0.365
</code></pre>

</div>
</div>
</article>
<!-- Presenter Notes -->
</slide>

<slide class="" id="slide-9" style="background:;">
<article data-timings="">

<div class="quiz-text quiz-multitext well">
<p>If you roll ten standard dice, take their average, then repeat this process over and over and construct a histogram, </p>

<ol>
<li>what would it be centered at?</li>
</ol>

<button class="quiz-submit btn btn-primary">Submit</button>
<button class="quiz-toggle-hint btn btn-info">Show Hint</button>
<button class="quiz-show-answer btn btn-success">Show Answer</button>
<button class="quiz-clear btn btn-danger">Clear</button>

<div class="quiz-hint">
<p>\(E[X_i] = E[\bar X]\) where \(\bar X = \frac{1}{n}\sum_{i=1}^n X_i\)</p>

</div>
<div class="quiz-explanation">
<p>The answer will be <span class="answer">3.5</span> since the mean of the
sampling distribution of iid draws will be the population mean that the
individual draws were taken from.</p>

</div>
</div>
</article>
<!-- Presenter Notes -->
</slide>

<slide class="" id="slide-10" style="background:;">
<article data-timings="">

<div class="quiz-text quiz-multitext well">
<p>If you roll ten standard dice, take their average, then repeat this process over and over and construct a histogram, </p>

<ol>
<li>what would be its variance expressed to 3 decimal places?</li>
</ol>

<button class="quiz-submit btn btn-primary">Submit</button>
<button class="quiz-toggle-hint btn btn-info">Show Hint</button>
<button class="quiz-show-answer btn btn-success">Show Answer</button>
<button class="quiz-clear btn btn-danger">Clear</button>

<div class="quiz-hint">
<p>\[Var(\bar X) = \sigma^2 /n\]</p>

</div>
<div class="quiz-explanation">
<p>The answer will be <span class="answer">0</span>
since the variance of the sampling distribution of the mean is \(\sigma^2/12\)
and the variance of a die roll is </p>

<pre><code class="r">mean((1 : 6 - 3.5)^2)
</code></pre>

<pre><code>[1] 2.917
</code></pre>

</div>
</div>
</article>
<!-- Presenter Notes -->
</slide>

<slide class="" id="slide-11" style="background:;">
<article data-timings="">

<div class="quiz-text quiz-multitext well">
<p>The number of web hits to a site is Poisson with mean 16.5 per day. </p>

<ol>
<li>What is the probability of getting 20 or fewer in 2 days expressed
as a percentage to one decimal place?</li>
</ol>

<button class="quiz-submit btn btn-primary">Submit</button>
<button class="quiz-toggle-hint btn btn-info">Show Hint</button>
<button class="quiz-show-answer btn btn-success">Show Answer</button>
<button class="quiz-clear btn btn-danger">Clear</button>

<div class="quiz-hint">
<p>Let \(X\) be the number of hits in 2 days then \(X \sim Poisson(2\lambda)\)</p>

</div>
<div class="quiz-explanation">
<p><span class="answer">1</span></p>

<pre><code class="r">round(ppois(20, lambda = 16.5 * 2) * 100, 1)
</code></pre>

<pre><code>[1] 1
</code></pre>

</div>
</div>
</article>
Expand Down Expand Up @@ -286,6 +473,36 @@ <h2>About these slides</h2>
6
</a>
</li>
<li>
<a href="#" target="_self" rel='tooltip'
data-slide=7 title=''>
7
</a>
</li>
<li>
<a href="#" target="_self" rel='tooltip'
data-slide=8 title=''>
8
</a>
</li>
<li>
<a href="#" target="_self" rel='tooltip'
data-slide=9 title=''>
9
</a>
</li>
<li>
<a href="#" target="_self" rel='tooltip'
data-slide=10 title=''>
10
</a>
</li>
<li>
<a href="#" target="_self" rel='tooltip'
data-slide=11 title=''>
11
</a>
</li>
</ul>
</div> <!--[if IE]>
<script
Expand Down
Loading

0 comments on commit 4b9e4c6

Please sign in to comment.