Ref:
https://onlinecourses.science.psu.edu/stat464/print/book/export/html/3
The Binomial Distribution in R:
# return PMF. prob is the probability of success . x can be a list
dbinom(x, size, prob) # CDF
pbinom(x, size, prob) # returns a value for a particular percentile
qbinom
The Normal Distribution in R:
dnorm(x, mean, sd)
# cdf
pnorm
# percentile
qnorm
要执行t-test或者查看置信区间,可以这样做:即设置数据、α的值。
> x=c(15, 18, 6, 20, 10, 11, 9, 6, 14, 14, 11, 8, 10, 1, 7, 1, 18, 17, 10, 9) > t.test(x, conf.level=0.95) One Sample t-test data: x
t = 9.0705, df = 19, p-value = 2.473e-08
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
8.26943 13.23057
sample estimates:
mean of x
10.75
如果是做假设检验,则需要设置μ0和备选假设。
> t.test(x, alternative="less", mu=10)
查看结果:
p值远大于0.05,所以,不能拒绝原假设。