[問題]該如何依序點對點畫箭頭
最近在實作梯度下降
想要畫出overshooting
https://imgur.com/S8JZMjp

以下是我的過程
x=seq(-3,3,0.01)
plot( x,x^2 ,type = "l" ,xlab = "x",ylab = "f(x)" )
R=10
#eta is learning rate
eta <- 2
#intail guess of x
intail_x <- -3
# objective function
f <- function(x) {x^2}
# partial objective function
partialf <-function(x) {2*x}
x=numeric(length=(R+1))
x[1] <-intail_x
for(i in 1:R){
x[i+1] <- x[i]-eta*partialf(x[i])
}
data.frame(x,y=f(x))
我有以下的點座標
https://imgur.com/JDxy3oK

想要畫出跟教科書一樣的圖 就是第一個點射到第二個點 第二個點在射到第三個點
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 219.91.75.186 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1585779113.A.B80.html
→
04/02 14:14,
5年前
, 1F
04/02 14:14, 1F
→
04/02 14:29,
5年前
, 2F
04/02 14:29, 2F
→
04/02 14:38,
5年前
, 3F
04/02 14:38, 3F
謝謝,後來用arrow解決了
※ 編輯: empireisme (101.12.53.3 臺灣), 04/02/2020 21:00:55
R_Language 近期熱門文章
PTT數位生活區 即時熱門文章