神魔.R

tchsieh — May 13, 2013, 12:14 AM

# 水遊戰鬥場數與技能升級的關係
# 資料來源: 巴哈 s5885121(小諾)
# http://forum.gamer.com.tw/C.php?bsn=23805&snA=22435&tnum=4&subbsn=1
# 分析 by T.C. Hsieh, 2013 May

x <- c(2, 3, 4, 5, 6, 7, 8)
y <- c(21,35,88,162,455,947,2748) 
options(warn=-1)
par(lwd=2, pch=19)
plot(x,log(y),type="p", xlab="Lv", ylab="log(Battle)", ylim=c(3, 10), xlim=c(2, 10),lwd=2, main="Regression")
g <- lm(log(y)~x)
abline(g, lwd=2)
pred <- rbind(x=2:10, y=exp(y.pred <- predict(g, data.frame(x=c(2:10)))))
points(9, predict(g, new=data.frame(x=9)), pch=1)
points(10, predict(g, new=data.frame(x=10)), pch=1)

plot of chunk unnamed-chunk-1

pred <- rbind(pred, LCL=exp(log(pred[2,]) - 1.96*summary(g)$sigma))
pred <- rbind(pred, UCL=exp(log(pred[2,]) + 1.96*summary(g)$sigma))

# x 表示技能等級
# y 表示需要戰鬥場數預測平均
# LCL表示至少需要戰鬥場數預測值 (95%信賴下界)
# UCL表示至多需要戰鬥場數預測值 (95%信賴上界)
round(pred)
     1  2   3   4   5    6    7    8     9
x    2  3   4   5   6    7    8    9    10
y   17 39  88 199 450 1019 2306 5217 11804
LCL 13 28  64 145 328  743 1681 3804  8606
UCL 24 53 121 273 618 1398 3163 7156 16191

plot(x,log(y),type="p", xlab="Lv", ylab="log(Battle)", ylim=c(3, 10), xlim=c(2, 10),lwd=2, main="Foo")
rect(0,0,6,6, lty=2)
rect(0,0,5,5, lty=2)
rect(0,0,7,7, lty=2)
rect(0,0,8,8, lty=2)
points(9, 9, pch=1)
points(10, 10, pch=1)
rect(0,0,9,9, lty=3)
rect(0,0,10,10, lty=3)

plot of chunk unnamed-chunk-1