optimizeR(Rmpfr)
optimizeR()所属R语言包:Rmpfr
High Precisione One-Dimensional Optimization
高Precisione一维优化
译者:生物统计家园网 机器人LoveR
描述----------Description----------
optimizeR searches the intervalfrom lower to upper for a minimum of the function f with respect to its first argument.
optimizeR搜索intervalfromlowerupper一个最低限度的功能f它的第一个参数。
用法----------Usage----------
optimizeR(f, lower, upper, ..., tol = 1e-20,
method = c("Brent", "GoldenRatio"),
maximum = FALSE,
precFactor = 2.0, precBits = -log2(tol) * precFactor,
maxiter = 1000, trace = FALSE)
参数----------Arguments----------
参数:f
the function to be optimized. f(x) must work “in Rmpfr arithmetic” for optimizer() to make sense. The function is either minimized or maximized over its first argument depending on the value of maximum.
函数来进行优化。 f(x)必须工作“Rmpfr算术”optimizer()是有道理的。功能被最小化或最大化的价值maximum在其第一个参数。
参数:...
additional named or unnamed arguments to be passed to f.
额外的命名和未命名的参数被传递到f。
参数:lower
the lower end point of the interval to be searched.
要搜索的下端的间隔的点。
参数:upper
the upper end point of the interval to be searched.
的上端部的间隔的点进行搜索。
参数:tol
the desired accuracy, typically higher than double precision, i.e., tol < 2e-16.
所需的精度,通常高于双精度,即,tol < 2e-16。
参数:method
character string specifying the optimization method. </table>
character字符串,该字符串指定的优化方法。 </ TABLE>
参数:maximum
logical indicating if f() should be maximized or minimized (the default).
逻辑表明,如果f()应最大化或最小化(默认值)。
参数:precFactor
only for default precBits construction: a factor to multiply with the number of bits directly needed for tol.
只为默认的precBits施工:为tol直接需要的比特的数目乘以一个因素。
参数:precBits
number of bits to be used for mpfr numbers used internally.
要用于mpfr数字内部使用的比特数。
参数:maxiter
maximal number of iterations to be used.
要使用的最大数目的迭代。
参数:trace
integer or logical indicating if and how iterations should be monitored; if an integer k, print every k-th iteration.
整数或逻辑表明,如果迭代应如何进行监控,如果整数k,打印每k个的迭代。
Details
详细信息----------Details----------
"Brent": Brent(1973)'s simple and robust algorithm is a hybrid, using a combination of the golden ratio and local quadratic (“parabolic”) interpolation. This is the same algorithm as standard R's optimize(), adapted to high precision numbers.
"Brent":布伦特(1973年)的简单而强大的算法是一个混合体,使用相结合的黄金比例和局部二次插值(“抛物线”)。这是标准的R optimize(),适用于高精确的数字相同的算法。
In smooth cases, the convergence is considerably faster than the golden section or Fibonacci ratio algorithms.
在光滑的情况下,融合是大大快于黄金地段,或斐波那契比率的算法。
"GoldenRatio": The golden ratio method works as follows: from a given interval containing the solution, it constructs the next point in the golden ratio between the interval boundaries.
"GoldenRatio":黄金比例方法的工作原理如下:从一个给定的时间间隔的解决方案,构建了下一个点之间的时间间隔边界的黄金比例。
值----------Value----------
A list with components minimum (or maximum) and objective which give the location of the minimum (or maximum) and the value of the function at that point; iter specifiying the number of iterations, the logical convergence indicating if the iterations converged and estim.prec which is an estimate or an upper bound of the final precision (in x). method the string of the method used.
Alist的组件的minimum(maximum)和objective的位置让给最小(或最大)值的函数在这一点上,“iter的specifiying的次数的迭代,逻辑convergence表示如果迭代收敛estim.prec是一个估计的或上限的最终精度(在x)。 method的字符串所使用的方法。
(作者)----------Author(s)----------
<code>"GoldenRatio"</code> is based on Hans W Borchert's
<code><a href="../../pracma/html/golden_ratio.html">golden_ratio</a></code>;
modifications and <code>"Brent"</code> by Martin Maechler.
参见----------See Also----------
R's standard optimize; Rmpfr's unirootR.
R的标准optimizeRmpfr的unirootR。
实例----------Examples----------
iG5 <- function(x) -exp(-(x-5)^2/2)
curve(iG5, 0, 10, 200)
o.dp <- optimize (iG5, c(0, 10)) #-> 5 of course[ - > 5]
oM.gs <- optimizeR(iG5, 0, 10, method="Golden")
oM.Br <- optimizeR(iG5, 0, 10, method="Brent", trace=TRUE)
oM.gs$min ; oM.gs$iter
oM.Br$min ; oM.Br$iter
## more accuracy:[#更准确的:]
oM.gs <- optimizeR(iG5, 0, 10, method="Golden", tol = 1e-70)
oM.Br <- optimizeR(iG5, 0, 10, tol = 1e-70)
rbind(Golden = c(err = as.numeric(oM.gs$min -5), iter = oM.gs$iter),
Brent = c(err = as.numeric(oM.Br$min -5), iter = oM.Br$iter))
## ==> Brent is orders of magnitude more efficient ![#==>布伦特数量级,更高效!]
## Testing on the sine curve with 40 correct digits:[#测试的40个正确的数字正弦曲线:]
sol <- optimizeR(sin, 2, 6, tol = 1e-40)
str(sol)
sol <- optimizeR(sin, 2, 6, tol = 1e-50,
precFactor = 3.0, trace = TRUE)
pi.. <- 2*sol$min/3
print(pi.., digits=51)
stopifnot(all.equal(pi.., Const("pi", 256), tol = 10*1e-50))
## a harder one:[#一个更难的问题:]
f.sq <- function(x) sin(x-2)^4 + sqrt(pmax(0,(x-1)*(x-4)))*(x-2)^2
curve(f.sq, 0, 4.5, n=1000)
msq <- optimizeR(f.sq, 0, 5, tol = 1e-50, trace=5)
str(msq) # ok[行]
stopifnot(abs(msq$minimum - 2) < 1e-49)
## find the other local minimum: -- non-smooth ==> Golden-section is used[#找到其他地方最低: - 非光滑==>金部分用于]
msq2 <- optimizeR(f.sq, 3.5, 5, tol = 1e-50, trace=10)
stopifnot(abs(msq2$minimum - 4) < 1e-49)
## and a local maximum:[#和本地最大:]
msq3 <- optimizeR(f.sq, 3, 4, maximum=TRUE, trace=2)
stopifnot(abs(msq3$maximum - 3.57) < 1e-2)
##----- "impossible" one to get precisely ------------------------[#-----“不可能的”,得到精确的------------------------]
curve(exp(-1/(x-8)^2), -3, 13, n=1001)
(opt. <- optimizeR(function(x) exp(-1/(x-8)^2), -3, 13, trace = 5))
## -> close to 8 {but not very close!}[号码 - >靠近{但是并不是很亲密!]
ff <- function(x) exp(-1/(x-8)^2)
ff(opt.$minimum) # gives 0[给出了0]
## try harder ... in vain ..[#努力...徒然..]
str(opt1 <- optimizeR(ff, -3,13, tol = 1e-60, precFactor = 4))
print(opt1$minimum, digits=20)
## still just 7.99998038 or 8.000036655 {depending on method}[#还只是7.99998038 8.000036655 {方法}]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|