一、Q&A

Q1:Given the 2016 Stat data set, estimate the final exam scores of 4 students who scores, say, 20, 40, 70, 90 (or more realistic scores of your interest) in the midterm Stat 2017.

Ans:根據我們的程式,用2016期中期末的關係線,把這4位同學帶入此關係線,得出在2017期中考20分的同學期末會考19.47841分、期中考40分的同學期末會考30.51201分、期中考70分的同學期末會考47.06241分、期中考90分的同學期末會考58.09601分。

Q2:According to an unidentified yet reliable source, the course grades given by instructor is roughly #A:#B:#C:#(D or E) ≈1:3:3:3

Ans:根據我們的程式,成績排名前六位的同學的分數就是A的分數區間為[100,78.5),第7名到第25名的分數就是B的分數區間為[78.5,44),第26名到第44名的分數就是C的分數區間為[44,24),第45名到第63名的分數就是(DorE)的分數區間為[24,0]。

Q3:Estimate the course grades of these 4 students. Please provide the assumptions and rationale of your estimation.

Ans:四位同學的總成績分別為24.7392、40.25601、63.5312、79.04801,分別落在C、C、B、A。

二、Process/Suppose

Q1:假設以給定的四位同學2016期中、期末成績繪圖而成的關係線會跟2017期中成績和要預估的2017期末成績繪圖而成的關係線相同下,因為已知2016期中與期末的常態分布圖,假設2017的期中和期末的常態分佈圖的關係線與2016相同,把2017四位已知分數代入2016期中期末關系線,來預測他們2017期末成績。

Q2:根據2016年的數據有63人的成績,比例是1:3:3:3,所以A=6.3、B=18.9、C=18.9、(DorE)=18.9,再從2016整體數據中找出成績排名前六位的同學的分數就是A的分數區間,接著第7名到第25名的分數就是B的分數區間,第26名到第44名的分數就是C的分數區間,第45名到第63名的分數就是(DorE)的分數區間。

Q3:假設2017的區間跟2016的區間是一樣的,把這四位同學的總成績算出來,再根據Q2的ABCDE 區間,判斷這四位同學在哪個區間。

三、code

Q1:

library(data.table)
exam <- fread('http://faculty.ndhu.edu.tw/~chtsao/ftp/stat2016.txt')
head(exam)   # Take a quick look of first few cases
##    V1 V2 V3
## 1:  2  5 36
## 2:  2 75 63
## 3:  2 37 38
## 4:  2 27  0
## 5:  2 16 14
## 6:  2 46 57
summary(exam)
##        V1              V2               V3        
##  Min.   :2.000   Min.   :  0.00   Min.   :-10.00  
##  1st Qu.:2.000   1st Qu.: 25.50   1st Qu.: 13.50  
##  Median :2.000   Median : 46.00   Median : 31.00  
##  Mean   :2.476   Mean   : 46.52   Mean   : 34.11  
##  3rd Qu.:3.000   3rd Qu.: 67.50   3rd Qu.: 53.00  
##  Max.   :5.000   Max.   :110.00   Max.   :100.00
is.data.frame(exam)
## [1] TRUE
colnames(exam)<-c("year","mid","final")
exam$year<-as.factor(exam$year)
summary(exam)
##  year        mid             final       
##  2:42   Min.   :  0.00   Min.   :-10.00  
##  3:15   1st Qu.: 25.50   1st Qu.: 13.50  
##  4: 3   Median : 46.00   Median : 31.00  
##  5: 3   Mean   : 46.52   Mean   : 34.11  
##         3rd Qu.: 67.50   3rd Qu.: 53.00  
##         Max.   :110.00   Max.   :100.00
attach(exam)
m2<-lm(final~mid)
summary(m2)
## 
## Call:
## lm(formula = final ~ mid)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -36.062 -12.562  -3.029  10.211  61.213 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  8.44481    5.14339   1.642    0.106    
## mid          0.55168    0.09554   5.774 2.79e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 20.54 on 61 degrees of freedom
## Multiple R-squared:  0.3534, Adjusted R-squared:  0.3428 
## F-statistic: 33.34 on 1 and 61 DF,  p-value: 2.791e-07
par(mfrow=c(2,2));  
plot(m2)

par(mfrow=c(1,1));  
plot(final~mid)
abline(m2)

a=20   #代入四位學生成績
y=0.55168*a+8.44481  #y=ax+b 線性方程式
y
## [1] 19.47841
b=40
y=0.55168*b+8.44481
y
## [1] 30.51201
c=70
y=0.55168*c+8.44481
y
## [1] 47.06241
d=90
y=0.55168*d+8.44481
y
## [1] 58.09601

Q2:

A=0.5*mid+0.5*final+5 #suppose by ourself
sort(A,decreasing=TRUE)  #遞減排列成績
##  [1] 96.5 91.5 87.5 86.5 82.5 81.5 78.5 74.0 73.5 70.5 69.0 67.0 66.0 65.5
## [15] 65.5 64.0 61.5 61.0 60.5 58.5 56.5 54.0 53.0 52.0 50.5 48.5 47.5 47.0
## [29] 46.5 45.5 44.5 44.0 43.5 43.0 42.5 42.5 41.5 40.5 36.5 35.5 33.0 32.5
## [43] 32.5 30.5 30.0 27.5 27.0 26.5 25.5 25.5 24.0 22.0 22.0 22.0 20.0 18.5
## [57] 16.5 16.5  9.5  8.5  5.5  3.0  0.5
a=63*1/10 #把人數分割成1:3:3:3
a
## [1] 6.3
round(a)  #大約值取四捨五入
## [1] 6
b=63*3/10
b
## [1] 18.9
round(b)
## [1] 19
c=63*3/10
c
## [1] 18.9
round(c)
## [1] 19
d=63*3/10
d
## [1] 18.9
round(d)
## [1] 19

Q3:

a=20*0.5+ 19.47841*0.5+5#把四位同學總成績算出來#運用A=0.5*mid+0.5*final+5 by Q2
a
## [1] 24.7392
b=40*0.5+ 30.51201*0.5+5
b
## [1] 40.25601
c=70*0.5+ 47.06241*0.5+5
c
## [1] 63.5312
d=90*0.5+ 58.09601*0.5+5
d
## [1] 79.04801

四、Discuss

Q1:在構思第一題如何解題時,我們先假設2017的成績常態分佈圖的關係線會與2016的成績常態分佈圖關係線大同小異,然後將2017的期中成績代入2016的關係線,求出2017期末的成績。在write code時,我們先讀入2016的成績數據常態分佈圖,找到關係線,利用線性方程式y=ax+b代入2017期中成績,求得y=期末成績。

Q2:第二題是求區間,我們先從2016的總成績數據裡得知總人數為63人,A、B、C、(DorE)區間的比例是1:3:3:3,分成A是前10%的同學,B是11%40%的同學,C是41%70%的同學,D是71%~100%的同學,得到A是前六名的同學,B是7到25名的同學,C是26名到44名的同學,D是45名到63名的同學,2016總成績我們假設期中除以2+期末除以2(因為不會大於100分),之後加上5(因為有同學的成績為負值,+5使它>0),再由求得的總成績用看的,看出前六名的同學,定義分數區間為A,以此類推。

Q3:假設2017的成績區間與2016的成績區間相同,算出2017四位同學的總成績,再用看的,看出四位同學的成績區間。