0
我想在我的函数GGG
中获得更精确(最多6位小数位)的x[1]
和x[2]
。是nlm()或优化()比R()更精确
使用optim
,我得到了一些精度高达3位小数,但我想知道如何提高至少6位小数的精度?
可以使用optimize
和nlm
达到这个目标吗?
GGG = function(Low, High, p1, p2) {
f <- function(x) {
y <- c(Low, High) - qcauchy(c(p1, p2), location=x[1], scale=x[2])
}
## SOLVE:
AA <- optim(c(1,1), function(x) sum(f(x)^2))
## return parameters:
parms = unname(AA$par)
return(parms) ## Correct but up to 3 decimal places
}
## TEST:
AAA <- GGG (Low = -3, High = 3, p1 = .025, p2 = .975)
## CHECK:
q <- qcauchy(c(.025, .975), AAA[1], AAA[2]) # What comes out of "q" MUST match "Low" and
# "High" up to 6 decimal places
亲爱的THC,非常感谢你。请问你是否可以修改你的回复[** HERE **](http://stackoverflow.com/questions/43286436/using-optimize-to-find-the-shortest-interval-that-takes-95-曲线区域)所以函数[** THERE **](http://stackoverflow.com/questions/43286436/using-optimize-to-find-the-shortest-interval-that-takes-95曲线区域)可以在所有情况下工作而无需手动***调整间隔? – rnorouzian