approxfun(stats)
approxfun()所属R语言包:stats
Interpolation Functions
插值函数
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Return a list of points which linearly interpolate given data points, or a function performing the linear (or constant) interpolation.
返回列表点线性插值给定的数据点,或一个函数进行线性插值(或常数)。
用法----------Usage----------
approx (x, y = NULL, xout, method="linear", n=50,
yleft, yright, rule = 1, f = 0, ties = mean)
approxfun(x, y = NULL, method="linear",
yleft, yright, rule = 1, f = 0, ties = mean)
参数----------Arguments----------
参数:x, y
vectors giving the coordinates of the points to be interpolated. Alternatively a single plotting structure can be specified: see xy.coords.
给点坐标的向量进行插值。或者指定一个单一的绘图结构可以看到xy.coords。
参数:xout
an optional set of values specifying where interpolation is to take place.
值指定插值发生的一组可选。
参数:method
specifies the interpolation method to be used. Choices are "linear" or "constant".
指定要使用的插值方法。选择是"linear"或"constant"。
参数:n
If xout is not specified, interpolation takes place at n equally spaced points spanning the interval [min(x), max(x)].
xout如果没有被指定,插值在n跨越间隔等距点[min(x),max(x)]。
参数:yleft
the value to be returned when input x values are less than min(x). The default is defined by the value of rule given below.
当输入x值比min(x)要返回的值。默认情况下被定义由rule下面给出的值。
参数:yright
the value to be returned when input x values are greater than max(x). The default is defined by the value of rule given below.
要返回的值时,输入x值比max(x)。默认情况下被定义由rule下面给出的值。
参数:rule
an integer (of length 1 or 2) describing how interpolation is to take place outside the interval [min(x), max(x)]. If rule is 1 then NAs are returned for such points and if it is 2, the value at the closest data extreme is used. Use, e.g., rule = 2:1, if the left and right side extrapolation should differ.
描述如何插值是一个整数(长度为1或2)区间以外的地方[min(x),max(x)]。如果rule是1然后NAS是这样的点,如果是2,在最近的数据极端值用于返回。使用,例如,rule = 2:1,如果左边和右边的推断应该有所不同。
参数:f
for method="constant" a number between 0 and 1 inclusive, indicating a compromise between left- and right-continuous step functions. If y0 and y1 are the values to the left and right of the point then the value is y0*(1-f)+y1*f so that f=0 is right-continuous and f=1 is left-continuous.
method="constant"之间的数字0和1的包容性,表示左,右连续阶梯函数的妥协。如果y0和y1点的左侧和右侧的值,然后该值是y0*(1-f)+y1*f所以f=0是正确的连续和f=1左连续。
参数:ties
Handling of tied x values. Either a function with a single vector argument returning a single number result or the string "ordered".
绑x值的处理。无论是一个向量参数返回一个单数的结果或字符串"ordered"的功能。
Details
详情----------Details----------
The inputs can contain missing values which are deleted, so at least two complete (x, y) pairs are required (for method = "linear", one otherwise). If there are duplicated (tied) x values and ties is a function it is applied to the y values for each distinct x value. Useful functions in this context include mean, min, and max. If ties="ordered" the x values are assumed to be already ordered. The first y value will be used for interpolation to the left and the last one for interpolation to the right.
输入可以包含缺少被删除的值,所以需要至少两个完整的(x, y)对(method = "linear",一个以其他方式)。如果有重复(并列)x值“ties是它适用于每一个不同的y值x值的功能。在这方面有用的功能包括mean,min,max。如果ties="ordered"x值被假定为已经订购。第一y值将用于插值到左边和插值权的最后一个。
值----------Value----------
approx returns a list with components x and y, containing n coordinates which interpolate the given data points according to the method (and rule) desired.
approx返回组件列表x和y,n坐标插值给定的数据点,根据method(rule )所需。
The function approxfun returns a function performing (linear or constant) interpolation of the given data points. For a given set of x values, this function will return the corresponding interpolated values. This is often more useful than approx.
功能approxfun返回一个功能不良的给定数据点插值(线性或常数)。给定为x值的,这个函数将返回相应的插补值。这往往是比approx更多有用。
参考文献----------References----------
The New S Language. Wadsworth & Brooks/Cole.
参见----------See Also----------
spline and splinefun for spline interpolation.
spline和splinefun样条插值。
举例----------Examples----------
require(graphics)
x <- 1:10
y <- rnorm(10)
par(mfrow = c(2,1))
plot(x, y, main = "approx(.) and approxfun(.)")
points(approx(x, y), col = 2, pch = "*")
points(approx(x, y, method = "constant"), col = 4, pch = "*")
f <- approxfun(x, y)
curve(f(x), 0, 11, col = "green2")
points(x, y)
is.function(fc <- approxfun(x, y, method = "const")) # TRUE[真]
curve(fc(x), 0, 10, col = "darkblue", add = TRUE)
## different extrapolation on left and right side :[左边和右边的#不同的推断:]
plot(approxfun(x, y, rule = 2:1), 0, 11,
col = "tomato", add = TRUE, lty = 3, lwd = 2)
## Show treatment of 'ties' :[#显示的关系的待遇:]
x <- c(2,2:4,4,4,5,5,7,7,7)
y <- c(1:6, 5:4, 3:1)
approx(x,y, xout=x)$y # warning[警告]
(ay <- approx(x,y, xout=x, ties = "ordered")$y)
stopifnot(ay == c(2,2,3,6,6,6,4,4,1,1,1))
approx(x,y, xout=x, ties = min)$y
approx(x,y, xout=x, ties = max)$y
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|