integrateR(Rmpfr)
integrateR()所属R语言包:Rmpfr
One-Dimensional Numerical Integration - in pure R
一维数值积分方法 - 在纯粹的研究
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Numerical integration of one-dimensional functions in pure R, with care so it also works for "mpfr"-numbers.
纯R,小心的一维函数的数值积分,所以它也可以用于"mpfr"号。
Currently, only classical Romberg integration of order ord is available.
目前,只有经典的Romberg积分的订单ord是可用的。
用法----------Usage----------
integrateR(f, lower, upper, ..., ord = NULL,
rel.tol = .Machine$double.eps^0.25, abs.tol = rel.tol,
verbose = FALSE)
参数----------Arguments----------
参数:f
an R function taking a numeric or "mpfr" first argument and returning a numeric (or "mpfr") vector of the same length. Returning a non-finite element will generate an error.
R的功能,以数字或"mpfr"第一个参数并返回一个数字(或"mpfr")相同长度的向量。返回一个非有限元会产生一个错误。
参数:lower, upper
the limits of integration. Currently must be finite.
集成的限制。目前必须是有限的。
参数:...
additional arguments to be passed to f.
额外的参数传递给f。
参数:ord
integer, the order of Romberg integration to be used. If this is NULL, as per default, the order is increased until convergence, see rel.tol and abs.tol.
整数,Romberg积分的顺序被使用。如果这是NULL,根据默认的,为了增加直到收敛,看到rel.tol和abs.tol。
参数:rel.tol
relative accuracy requested. The default is 1.2e-4.
相对精度的要求。默认值为1.2E-4。
参数:abs.tol
absolute accuracy requested.
绝对精度的要求。
参数:verbose
logical or integer, indicating if and how much information should be printed during computation.
在计算过程中,应印有逻辑或整数,表示多少信息。
Details
详细信息----------Details----------
Note that arguments after ... must be matched exactly.
需要注意的是参数后...必须完全匹配。
rel.tol cannot be less than max(50*.Machine$double.eps, 0.5e-28) if abs.tol <= 0.
rel.tol不能小于max(50*.Machine$double.eps, 0.5e-28)如果abs.tol <= 0的。
值----------Value----------
A list of class "integrate" with components
类"integrate"的组件的列表
参数:value
the final estimate of the integral.
积分的最终估值。
参数:abs.error
estimate of the modulus of the absolute error.
估计的弹性模量的绝对误差。
参数:subdivisions
for Romberg, the number of function evaluations.
容安澜,功能评估。
参数:message
"OK" or a character string giving the error message.
"OK"或字符的字符串,给出的错误信息。
参数:call
the matched call.
匹配的呼叫。
注意----------Note----------
f must accept a vector of inputs and produce a vector of function evaluations at those points. The Vectorize function may be helpful to convert f to this form.
f必须接受一个向量的投入,并在这些点上,产生一个向量功能评估。 Vectorize功能转换成f这种形式可能会有所帮助。
Note that the default tolerances (rel.tol, abs.tol) are not very accurate, but the same as for integrate, which however often returns considerably more accurate results than requested. This is typically not the case for integrateR().
请注意,默认的公差(rel.tol,abs.tol)是不是很准确,但同样为integrate,但经常返回相当多的准确的结果比要求的。这是通常的情况下integrateR()。
(作者)----------Author(s)----------
Martin Maechler
参考文献----------References----------
Algorithm 60 – Romberg Integration, Communications of the ACM 4(6), p.255.
参见----------See Also----------
R's standard, integrate, is much more adaptive, also allowing infinite integration boundaries, and typically considerably faster for a given accuracy.
R的标准,integrate,更是自适应,还可以无穷积分的界限,通常对于一个给定的精度相当快。
We use the same (actually a copy) print S3 method, print.integrate(), as provided by R.
我们使用相同(实际上是复制)printS3方法,print.integrate(),所提供的R.
实例----------Examples----------
## See more from ?integrate[#查看更多吗?整合]
## this is in the region where integrate() can get problems:[#这是在该区域的积分()可以得到问题:]
integrateR(dnorm,0,2000)
integrateR(dnorm,0,2000, rel.tol=1e-15)
integrateR(dnorm,0,2000, rel.tol=1e-15, verbose=TRUE)
## Demonstrating that 'subdivisions' is correct:[#表明,“细分”是正确的:]
Exp <- function(x) { .N <<- .N+ length(x); exp(x) }
.N <- 0; str(integrateR(Exp, 0,1, rel.tol=1e-10), digits=15); .N
### Using high-precision functions -----[##使用高精确度的功能-----]
## Polynomials are very nice:[多项式是很不错的:]
integrateR(function(x) (x-2)^4 - 3*(x-3)^2, 0, 5, verbose=TRUE)
# n= 1, 2^n= 2 | I = 46.04, abs.err = 98.9583[N = 1,2 ^ N = 2 | I = 46.04,abs.err = 98.9583]
# n= 2, 2^n= 4 | I = 20, abs.err = 26.0417[n = 2时,2 ^ n = 4时,| I = 20,abs.err = 26.0417]
# n= 3, 2^n= 8 | I = 20, abs.err = 7.10543e-15[n = 3时,2 ^ n的| I = 8 = 20,abs.err = 7.10543e-15]
## 20 with absolute error < 7.1e-15[#20绝对误差<7.1e-15]
I <- integrateR(function(x) (x-2)^4 - 3*(x-3)^2, 0, mpfr(5,128),
rel.tol = 1e-20, verbose=TRUE)
I ; I$value ## all fine[#所有罚款]
## with floats:[#与浮:]
integrateR(exp, 0 , 1, rel.tol=1e-15, verbose=TRUE)
## with "mpfr":[#与“MPFR”:]
(I <- integrateR(exp, mpfr(0,200), 1, rel.tol=1e-25, verbose=TRUE))
(I.true <- exp(mpfr(1, 200)) - 1)
## true absolute error:[#真正的绝对误差:]
stopifnot(print(as.numeric(I.true - I$value)) < 4e-25)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|