作者wheado (principal component QQ)
看板R_Language
标题[问题] 如何 print "optim" 的 iteration?
时间Tue Nov 8 17:51:19 2016
[问题类型]:
程式谘询(我想用R 做某件事情,但是我不知道要怎麽用R 写出来)
[软体熟悉度]:
入门(写过其他程式,只是对语法不熟悉)
[问题叙述]:
我想在执行optim的时候,show出optim每次跌代时的次数和更新後的值。
在执行完optim後虽然可以找到,但我想要在他每次跌代的时候,
都可以print出来。但是我在网路上找不太到。
[程式范例]:
fr <- function(x) {
x1 <- x[1]
x2 <- x[2]
100 * (x2 - x1 * x1)^2 + (1 - x1)^2
}
optim(par=c(1,2),fr,method="CG")
[环境叙述]:
R-3.3.1
[关键字]:
How to show iteration of optim in R?
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 58.114.225.29
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/R_Language/M.1478598681.A.2FF.html
1F:推 ksherry: 如果gradient函数不太复杂 可考虑自己写 11/08 18:43
2F:推 Edster: 在control = list(trace=TRUE) 11/08 20:20
3F:→ Edster: example 有教. 11/08 20:21