2019290183 姜朱玹 Tijiaoyong2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
install.packages("vcd")
install.packages("psych")
install.packages("data.table") #执行命令library(gclus)
# latest development version:data.table::update.dev.pkg()
install.packages("e1071")
library(e1071)
library(vcd)
library(data.table)

# 4.1 根据上表数据计算:

Q4_1 <- fread("/Users/gangjuhyeon/Library/Containers/com.tencent.xinWeChat/Data/Library/Application Support/com.tencent.xinWeChat/2.0b4.0.9/9a25b20e8340851a9ae8f3a299cadc43/Message/MessageTemp/ad60c7a88dc02d41701944eea7274b52/File/《统计学—基于R》(第3版)—例题和习题数据(公开资源)/exercise/ch4/第4章 习题CSV格式数据/exercise4_1.csv"
,stringsAsFactors=TRUE, header = FALSE,col.names = c(1,)) #Fast reading csv file using fread()

#(1) 有2~5台(包括2台与5台在内)冷气机出现重要缺陷的概率
sum(Q4_1[2,c(4,5,6,7)])
#(2) 只有不到2台冷气机出现重要缺陷的概率
sum(Q4_1[2,c(2,3)])
#(3) 有超过5台冷气机出现重要缺陷的概率
sum(Q4_1[2,c(7,8,9,10,11,12)])

# 4.2 设X是参数为n=4 和 p=0.1的二项随机变量。
#(1) P(X=2);
dbinom(2,4,0.1)
#(2) P(X<=1)
dbinom(0,4,0.1)+dbinom(1,4,0.1)

#4.3 计算以下概率和分位点:
#(1) X~N(500,20^2): P(X>=510);P(400<=X<=450).
#X1 <- Q4_1[2,c(2,3,4,5,6,7,8,9,10,11,12)]
#X1 <- numeric(X1)
X1 <- c(0.041, 0.130, 0.209, 0.223, 0.178, 0.114, 0.061, 0.028, 0.011, 0.004, 0.001)
Y1 <- dnorm(X1, mean=500, sd=20)
Y2 <- pnorm(q=c(510),mean=500,sd=20,lower.tail=FALSE)
Y2

Y4 <- pnorm(q=c(450),mean=500,sd=20)
Y5 <- pnorm(q=c(400),mean=500,sd=20)
Y6 <- Y4-Y5
Y6
#(2) Z~N(0,1): P(0<=Z<=1.2);P(-0.48<=Z<=0);P(Z>=1.2)
Z1 <- c(0.041, 0.130, 0.209, 0.223, 0.178, 0.114, 0.061, 0.028, 0.011, 0.004, 0.001)
z1 <- dnorm(Z1, mean=0, sd=1)
z2 <- pnorm(q=c(1.2),mean=0,sd=1)
z3 <- pnorm(q=c(0),mean=0,sd=1)
z4 <- z2 - z3
z5 <- pnorm(q=c(-0.48),mean=0,sd=1)
z6 <- pnorm(q=c(1.2),mean=0,sd=1,lower.tail=FALSE)
z7 <- z3-z5

#(3) 标准正态分布累积概率为0.95时的反函数值z
qnorm(p=0.95, mean=0,sd=1,lower.tail=TRUE)

#4.4 计算以下概率和分位点:
#(1) X~t(df), df=15, t值小于-1.5的概率;
#df=20,t值大于2的概率;
#df=30,t分布右尾概率为0.05时的t值
pt(q=-1.5,df=15,lower.tail = TRUE)
pt(q=2,df=20,lower.tail = FALSE)
qt(p=0.05,df=30,lower.tail = FALSE)

#(2) X~X^2(df), df=8, x^2值小于12的概率;
#df=20,x^2值大于18的概率;
#df=15,x^2分布右尾概率为0.05时的t值
pchisq(q=12, df=8, lower.tail = TRUE)
pchisq(q=18, df=20, lower.tail = FALSE)
qchisq(p=0.05, df=15, lower.tail = FALSE)

#(3) X~F(df1,df2), df1=15, df2=10,F值小于3.5的概率;
#df1=12,df2=8,F值大于3的概率,
#df1=20,df2=16,F分布右尾概率为0.025时的F值。
pf(q=3.5, df1=15,df2=10,lower.tail = TRUE)
pf(q=3, df1=12, df2=8, lower.tail = FALSE)
qf(p=0.025, df1=20, df2=16,lower.tail = FALSE )


Donate
  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
  • Copyrights © 2020 GwenChanEn
  • Visitors: | Views:

Do you like my writing? Would you coffee me?

支付宝
微信