这个作业是用R语言分析人口平均数等

STA255 Assignment#1
24/03/2020
Question 1
Suppose we have a population of size 5 and the corresponding numbers are: 21, 22, 23, 24, 25
(a) The population mean
population <- c(21, 22, 23, 24, 25)
mean(population)
## [1] 23
(b) The population variance
var(population)
## [1] 2.5
(c) Taking samples of size n=3 from the population with replacement
expand.grid(c(21:25), c(21:25), c(21:25))
## Var1 Var2 Var3
## 1 21 21 21
## 2 22 21 21
## 3 23 21 21
## 4 24 21 21
## 5 25 21 21
## 6 21 22 21
## 7 22 22 21
## 8 23 22 21
## 9 24 22 21
## 10 25 22 21
## 11 21 23 21
## 12 22 23 21
## 13 23 23 21
## 14 24 23 21
## 15 25 23 21
## 16 21 24 21
## 17 22 24 21
## 18 23 24 21
## 19 24 24 21
## 20 25 24 21
## 21 21 25 21
## 22 22 25 21
## 23 23 25 21
## 24 24 25 21
1
## 25 25 25 21
## 26 21 21 22
## 27 22 21 22
## 28 23 21 22
## 29 24 21 22
## 30 25 21 22
## 31 21 22 22
## 32 22 22 22
## 33 23 22 22
## 34 24 22 22
## 35 25 22 22
## 36 21 23 22
## 37 22 23 22
## 38 23 23 22
## 39 24 23 22
## 40 25 23 22
## 41 21 24 22
## 42 22 24 22
## 43 23 24 22
## 44 24 24 22
## 45 25 24 22
## 46 21 25 22
## 47 22 25 22
## 48 23 25 22
## 49 24 25 22
## 50 25 25 22
## 51 21 21 23
## 52 22 21 23
## 53 23 21 23
## 54 24 21 23
## 55 25 21 23
## 56 21 22 23
## 57 22 22 23
## 58 23 22 23
## 59 24 22 23
## 60 25 22 23
## 61 21 23 23
## 62 22 23 23
## 63 23 23 23
## 64 24 23 23
## 65 25 23 23
## 66 21 24 23
## 67 22 24 23
## 68 23 24 23
## 69 24 24 23
## 70 25 24 23
## 71 21 25 23
## 72 22 25 23
## 73 23 25 23
## 74 24 25 23
## 75 25 25 23
## 76 21 21 24
## 77 22 21 24
## 78 23 21 24
2
## 79 24 21 24
## 80 25 21 24
## 81 21 22 24
## 82 22 22 24
## 83 23 22 24
## 84 24 22 24
## 85 25 22 24
## 86 21 23 24
## 87 22 23 24
## 88 23 23 24
## 89 24 23 24
## 90 25 23 24
## 91 21 24 24
## 92 22 24 24
## 93 23 24 24
## 94 24 24 24
## 95 25 24 24
## 96 21 25 24
## 97 22 25 24
## 98 23 25 24
## 99 24 25 24
## 100 25 25 24
## 101 21 21 25
## 102 22 21 25
## 103 23 21 25
## 104 24 21 25
## 105 25 21 25
## 106 21 22 25
## 107 22 22 25
## 108 23 22 25
## 109 24 22 25
## 110 25 22 25
## 111 21 23 25
## 112 22 23 25
## 113 23 23 25
## 114 24 23 25
## 115 25 23 25
## 116 21 24 25
## 117 22 24 25
## 118 23 24 25
## 119 24 24 25
## 120 25 24 25
## 121 21 25 25
## 122 22 25 25
## 123 23 25 25
## 124 24 25 25
## 125 25 25 25
(d) For each of these samples of size 3, calculate the sample mean
3