Stat2.3x Inference(统计推断)课程由加州大学伯克利分校(University of California, Berkeley)于2014年在edX平台讲授。

PDF笔记下载(Academia.edu)

Summary

  • Test of Hypotheses $$\text{Null}: H_0$$ $$\text{Alternative}: H_A$$ Assuming the null is true, the chance of getting data like the data in the sample or even more like the alternative: P-value. If $P$ is small (i.e. cutoff), choose the alternative. Otherwise, stay with the null.
  • Significance Level and Power
    • Significance level is the probability, under $H_0$, that the test concludes $H_A$ error probability, should be small.
    • Power is the probability, under $H_A$, that the test concludes $H_A$ probability of correct conclusion, should be large.

ADDITIONAL PRACTICE PROBLEMS FOR EXERCISE SET 2

PROBLEM 1

To test whether “red” comes up 18/38 of the time in spins of a roulette wheel, the wheel is spun 3800 times; the result is “red” 1720 times. Is the wheel biased against “red”? Answer the question in the following steps:

a) Formulate null and alternative hypotheses about p, the chance with which the wheel shows “red”.

b) Calculate an exact P-value or its normal approximation.

c) State the conclusion of the test.

Solution

a) $$\text{Null}: p=\frac{18}{38}$$ $$\text{Alternative}: p < \frac{18}{38}$$

b) Binomial distribution (exact) $n=3800, p=\frac{18}{38}, k=0:1720$: $$P(p < \frac{18}{38})=\sum_{k=0}^{1720}C_{3800}^{k}\cdot p^k\cdot(1-p)^{3800-k}=0.004871166$$R code:

sum(dbinom(0:1720, 3800, 18/38))
[1] 0.004871166

Normal distribution (approximate): $\mu=n\cdot p=1800, \sigma=\sqrt{n\cdot p\cdot(1-p)}$: $$Z=\frac{1720.5-\mu}{\sigma}\Rightarrow P(p < \frac{18}{38})=0.004898679$$ R code:

n = 3800; p = 18 / 38; mu = n * p; sigma = sqrt(n * p * (1 - p))
z = (1720.5 - mu) / sigma
pnorm(z)
[1] 0.004898679

c) $P$ is very small so reject Null, that is, the wheel is biased against "red".

PROBLEM 2

In a “blind taste test” during a nationally televised football game, each of 100 “loyal Budweiser drinkers” was given two unmarked beer containers and asked to say which one they liked better. One of the containers had Budweiser and the other had Schlitz. Of the 100 participants, 46 said they liked the Schlitz better. Schlitz said this was an impressive showing. But maybe the subjects just couldn’t tell one beer from another. Test whether the results are or aren’t like tossing a coin, by providing:

a) the null and alternative hypotheses

b) the P-value

c) the conclusion of the test

Solution

a) $$\text{Null}: p=0.5$$ $$\text{Alternative}: p\neq0.5$$

b) Binomial distribution: $$\sum_{i=0}^{46}C_{100}^{i}\cdot p^i\cdot(1-p)^{100-i}+\sum_{j=54}^{100}C_{100}^{j}\cdot p^j\cdot(1-p)^{100-j}=0.4841184$$ R code:

sum(dbinom(0:46, 100, 0.5)) + sum(dbinom(54:100, 100, 0.5))
[1] 0.4841184

Normal approximation: $$\mu=100\times0.5=50, \sigma=\sqrt{100\times0.5\times0.5}=5$$ $$\Rightarrow Z=\frac{46.5-\mu}{\sigma}, P=0.4839273$$ R code:

n = 100; p = 0.5;
mu = n * p; sigma = sqrt(n * p * (1 - p))
z = (46.5 - mu) / sigma
2 * pnorm(z)
[1] 0.4839273

c) $P$ is huge so reject Alternative, that is, the results are look like tossing a coin.

PROBLEM 3

I have a bag of 100 M&M’s (known as Smarties in some countries; students who recognize neither should please think of them as colored pieces of candy). I think 20 of them are red, and my friend thinks that more than 20 are red. In order to decide between these two hypotheses, we are going to take a simple random sample of 40 M&M’s from the bag. If more than 10 M&M’s in the sample are red, we’ll choose my friend’s hypothesis, and otherwise we’ll choose mine. a) State the null hypothesis that is being tested. b) The significance level of the test is exactly (pick one option and fill in the blanks):

(i) binomial n = _____, p = ______, k in the range _______. (ii) hypergeometric N = ____, G = _____, n = _______, g in the range _____. c) Suppose that in fact there are 30 red M&M’s in the bag. The power of the test against this alternative is exactly (pick one option and fill in the blanks): (i) binomial n = _____, p = ______, k in the range _______.

(ii) hypergeometric N = ______, G = _______, n = _________, g in the range ______.

Solution

a) $H_0:$ there are 20 red in the bag.

b) The significance level is under $H_0$ but concludes $H_A$ (reject $H_0$), this is Type 1 error. $P$ should be small in this case. Hypergeometric distribution: $$N=100, G=20, n=40, g=11:20$$ $$\Rightarrow P=\frac{\sum_{g=11}^{20}C_{20}^{g}\cdot C_{80}^{40-g}}{C_{100}^{40}}=0.1017439$$ R code:

sum(dhyper(11:20, 20, 80, 40))
[1] 0.1017439

c) The power is under $H_A$ and concludes $H_A$, this is correct answer and $P$ should be large. Hypergeometric distribution: $$N=100, G=30, n=40, g=11:30$$ $$\Rightarrow P=\frac{\sum_{g=11}^{30}C_{30}^{g}\cdot C_{70}^{40-g}}{C_{100}^{40}}=0.7466689$$ R code:

sum(dhyper(11:30, 30, 70, 40))
[1] 0.7466689

PROBLEM 4

In order to test whether or not a random number generator is producing the digit “0” in the correct proportion (1/10), the generator will be run 5,000 times. You can assume that the runs are mutually independent and that each has the same probability p of producing “0”. Construct a test that has a significance level of approximately 1%. [Note: “Construct a test” means “Come up with a decision rule.” In the context of this problem, that means you have to say how you will use the number of 0’s among your 5,000 results to decide between your hypotheses.]

Solution $$H_0: p=0.1,\ H_A: p\ne0.1$$ The significance level is $1%$ means concluding $H_A$ while assuming $H_0$ is right. Under $H_0$, by normal approximation: $$n=5000, p=0.1\Rightarrow\mu=n\cdot p=500, \sigma=\sqrt{n\cdot p\cdot(1-p)}$$ This is two-tail test which means each tail is 0.005, so $Z=\pm2.575829$ R code:

qnorm(1 - 0.005)
[1] 2.575829

Thus, the cutoffs are $\mu\pm Z\cdot\sigma=[445.2084,554.7916]$ R code:

n = 5000; p = 0.1
sigma = sqrt(n * p * (1 - p)); mu = n * p
mu + z * sigma
[1] 445.2084
mu - z * sigma
[1] 554.7916

The test is: choose $H_A$ if the number of 0 is 445 or less, or 555 or more; otherwise stay with $H_0$.

EXERCISE SET 2

If a problem asks for an approximation, please use the methods described in the video lecture segments. Unless the problem says otherwise, please give answers correct to one decimal place according to those methods. Some of the problems below are about simple random samples. If the population size is not given, you can assume that the correction factor for standard errors is close enough to 1 that it does not need to be computed. Please use the 5% cutoff for P-values unless otherwise instructed in the problem.

PROBLEM 1

A die is rolled 600 times. The face with six spots appears 112 times. Is the die biased towards that face, or is this just chance variation? Answer the question in the steps outlined in Problems 1A-1F.

1A

a. The null hypothesis is

b. The die is biased towards the face with six spots.

c. The chance that the face with six spots appears is greater than 1/6, and the face appeared 112 times in the sample just by chance.

d. The chance that the face with six spots appears is equal to 1/6, and the face appeared 112 times in the sample just by chance.

e. The die is biased towards the faces that don’t show six spots.

f. The chance that the face with six spots appears is equal to 112/600.

g. The proportion of times the face with six spots appears is equal to 112/600.

1B The alternative hypothesis is

a. The die is biased.

b. The chance that the face with six spots appears is greater than 1/6.

c. The chance that the face with six spots appears is equal to 112/600.

d. The proportion of times the face with six spots appears is equal to 112/600.

1C If the null hypothesis were true, the expected number of times the face with six spots appeared would be 112 100

1D If the null hypothesis were true, the standard error of the number of times the face with six spots appeared would be _____.

1E The P-value of the test is _____%. [Please be careful to enter your answer as a percent; that is, if your answer is 50% you should enter 50 in the blank, not 50%, nor 0.5, nor 1/ 2, etc]

1F “The test concludes that the die is biased towards the face with six spots.” True  False

Solution

1A) d is correct. $$H_0: p=\frac{1}{6}$$

1B) b is correct. $$H_A: p > \frac{1}{6}$$

1C) $$n\cdot p=600\times\frac{1}{6}=100$$

1D) $$\sigma=\sqrt{n\cdot p\cdot(1-p)}=9.128709$$

1E) Binomial distribution: $$\sum_{k=112}^{600}C_{600}^{k}\cdot p^k\cdot(1-p)^{600-k}=10.50586\%$$ R code:

sum(dbinom(112:600, 600, 1/6))
[1] 0.1050586

1F) Because $P > 5\%$ cutoff, so reject $H_A$ (choose $H_0$). The answer is False.

PROBLEM 2

A statistics student hands each of 300 classmates 2 cookies side by side on a plate. Of the 300 students, 171 choose the cookie that’s on their right hand side, and the remaining 129 choose the cookie that’s on their left. The student says, “That’s just like tossing a coin.” The student’s friend says, “No, it’s not.” Help them settle their argument by performing a one-sample z test in Problems 2A-2C.

2A The test should be one-tailed. two-tailed.

2B The P-value of the test is _____%.

2C The test concludes: “That’s just like tossing a coin.” “No, it’s not.”

Solution

2A) $$H_0: p=0.5,\ H_A: p\neq0.5$$ Thus it is two-tailed.

2B) Binomial distribution: $n=300, p=0.5, k=0:129\ \&\ 171:300$:$$\sum_{i=0}^{129}C_{300}^{i}\cdot p^i\cdot(1-p)^{300-i}+\sum_{j=171}^{300}C_{300}^{j}\cdot p^j\cdot(1-p)^{300-j}=1.777934\%$$ R code:

sum(dbinom(0:129, 300, 0.5)) + sum(dbinom(171:300, 300, 0.5))
[1] 0.01777934

2C) $P < 5\%$, so reject $H_0$. That is, it is not like tossing a coin.

PROBLEM 3

There are two boxes, each with several million tickets marked “1” or “0”. The two boxes have the same number of tickets, but in one of the boxes, 49% of the tickets are marked “1” and in the other box 50.5% of the tickets are marked “1”. Someone hands me one of the boxes but doesn’t tell me which box it is. Consider the following hypotheses: Null: p = 0.49 Alternative: p = 0.505 Here is my proposed test: I will draw a simple random sample of 10,000 tickets, and if 5,000 or more of them are marked “1” then I will choose the alternative; otherwise I will stay with the null.

3A The significance level of my test is _____%.

3B The power of my test is _____%.

Solution

3A) The significance level is the probability of under $H_0$ but concludes $H_A$. Thus, by binomial distribution $p=0.49$ in this case: $$\sum_{k=5000}^{10000}C_{10000}^{k}\cdot0.49^k\cdot0.51^{10000-k}=2.328171\%$$ R code:

sum(dbinom(5000:10000, 10000, 0.49))
[1] 0.02328171

3B) The power is the probability of under $H_A$ and concludes $H_A$. Thus, by binomial distribution $p=0.505$ in this case: $$\sum_{k=5000}^{10000}C_{10000}^{k}\cdot0.505^k\cdot0.495^{10000-k}=84.37643\%$$ R code:

sum(dbinom(5000:10000, 10000, 0.505))
[1] 0.8437643

PROBLEM 4

There are 21,000 students in a Statistics MOOC. Each student tests the fairness of a coin (yes, the same coin; the instructor somehow gets Tyche’s help in getting the coin to each student in turn). Specifically, each student tests: Null: p is equal to 0.5 Alternative: p is not equal to 0.5 using the 5% cutoff. Suppose that, unknown to the students, the coin is in fact fair. The expected number of students whose test will conclude that the coin is unfair is __________. [This answer is actually an integer, cleanly calculated; but I’ll allow you an error of +-5.]

Solution

The chance that a single student makes the wrong conclusion under the null is 5%; that’s what the cutoff represents. So the number of students who make the wrong conclusion under the null is binomial with $n=21000, p=0.05$. The expected value is $21000\times0.05=1050$.

加州大学伯克利分校Stat2.3x Inference 统计推断学习笔记: Section 2 Testing Statistical Hypotheses的更多相关文章

  1. 加州大学伯克利分校Stat2.3x Inference 统计推断学习笔记: Section 5 Window to a Wider World

    Stat2.3x Inference(统计推断)课程由加州大学伯克利分校(University of California, Berkeley)于2014年在edX平台讲授. PDF笔记下载(Acad ...

  2. 加州大学伯克利分校Stat2.3x Inference 统计推断学习笔记: Section 4 Dependent Samples

    Stat2.3x Inference(统计推断)课程由加州大学伯克利分校(University of California, Berkeley)于2014年在edX平台讲授. PDF笔记下载(Acad ...

  3. 加州大学伯克利分校Stat2.3x Inference 统计推断学习笔记: Section 3 One-sample and two-sample tests

    Stat2.3x Inference(统计推断)课程由加州大学伯克利分校(University of California, Berkeley)于2014年在edX平台讲授. PDF笔记下载(Acad ...

  4. 加州大学伯克利分校Stat2.3x Inference 统计推断学习笔记: Section 1 Estimating unknown parameters

    Stat2.3x Inference(统计推断)课程由加州大学伯克利分校(University of California, Berkeley)于2014年在edX平台讲授. PDF笔记下载(Acad ...

  5. 加州大学伯克利分校Stat2.3x Inference 统计推断学习笔记: FINAL

    Stat2.3x Inference(统计推断)课程由加州大学伯克利分校(University of California, Berkeley)于2014年在edX平台讲授. PDF笔记下载(Acad ...

  6. 加州大学伯克利分校Stat2.2x Probability 概率初步学习笔记: Final

    Stat2.2x Probability(概率)课程由加州大学伯克利分校(University of California, Berkeley)于2014年在edX平台讲授. PDF笔记下载(Acad ...

  7. 加州大学伯克利分校Stat2.2x Probability 概率初步学习笔记: Section 5 The accuracy of simple random samples

    Stat2.2x Probability(概率)课程由加州大学伯克利分校(University of California, Berkeley)于2014年在edX平台讲授. PDF笔记下载(Acad ...

  8. 加州大学伯克利分校Stat2.2x Probability 概率初步学习笔记: Section 4 The Central Limit Theorem

    Stat2.2x Probability(概率)课程由加州大学伯克利分校(University of California, Berkeley)于2014年在edX平台讲授. PDF笔记下载(Acad ...

  9. 加州大学伯克利分校Stat2.2x Probability 概率初步学习笔记: Section 3 The law of averages, and expected values

    Stat2.2x Probability(概率)课程由加州大学伯克利分校(University of California, Berkeley)于2014年在edX平台讲授. PDF笔记下载(Acad ...

随机推荐

  1. 某站出品2016织梦CMS进阶教程共12课(附文档+工具)

    此为广告商内容使用最新版的dede cms建站 V5.7 sp1,经常注意后台的升级信息哦!一.安装DEDE的时候数据库的表前缀,最好改一下,不用dedecms默认的前缀dede_,随便一个名称即可. ...

  2. python网络编程学习《一》

    最近,刚实习完,很喜欢实验楼,但是自己的方向仍然不能确定,自己觉得可选择的空间很大,尽管已经是大四的人了,想到别人都在忙着买职业装,买高跟鞋面试,学习化妆什么的,看看自己,反而开始慢慢关注运动,食疗以 ...

  3. 你能熟练使用Dictionary字典和List列表吗?(转)

    命名空间System.Collections.Generic中有两个非常重要,而且常用的泛型集合类,它们分别是Dictionary<TKey,TValue>字典和List<T> ...

  4. C/C++代码覆盖工具gcov与lcov入门

    C/C++代码覆盖工具gcov与lcov入门 gcov是一个可用于C/C++的代码覆盖工具,是gcc的内建工具.下面介绍一下如何利用gcov来收集代码覆盖信息.想要用gcov收集代码覆盖信息,需要在g ...

  5. 前端人员一定要掌握的PS技巧

    一.PS与前端知多少 一般我们会认为PS是用来修改图片的,这些工作是美工人员做的事不是前端人员做的,其实这样想你就错了,因为在前端人员也是要学会一些简单的关于PS的技巧的,这样就不会应为一点点小小的需 ...

  6. TextBoxFor控件的扩展---Bootstrap在mvc上的应用

    TextBoxFor控件的问题: 1:自带了样式,再用bootstrap样式会有冲突. 2:要加水印,js事件,限制输入长度比较麻烦. 因此需要对textboxfor控件进行扩展. 目标: 1:能使用 ...

  7. SDRAM操作原理分析

    芯片原理图 引脚原理图 指令 通过对上面指令的总结,简化出要用到的指令如下: 指令 常量名 CKE CSn RAS CASn WEn 备注 空操作 NOP 1 0 1 1 1   行激活 ACTIVE ...

  8. 乱码电路(Garbled circuits)

    乱码电路(Garbled circuits)是Andrew Yao教授在上世纪80年代发明的一种很聪明的技术.它可以让两个人针对某个算式来计算答案,而不需要知道他们在计算式所输入的数字. 举个例子说, ...

  9. stack 栈的实现

    今天晚上去「南哪」听了场AI的讲座,除了话筒真心不给力之外,算是对微软这方面的进展有了更多了解,毕竟是半宣传性质的活动吧. 光听这些是没用的,眼下还是打好基础,多尝试学点新技术,拓宽能力和视野比较重要 ...

  10. jq mobile非ajax加载,ready执行两次

    jqm只有通过ajax加载的页面才只执行一次ready(正常情况) 页面刷新(同非ajax加载的页面)都会执行两次ready,包括pageinit和pageshow事件也是如此. 两种避免的方法是: ...