找回密码
 注册
查看: 3478|回复: 0

R语言:splinefun()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-16 20:00:33 | 显示全部楼层 |阅读模式
splinefun(stats)
splinefun()所属R语言包:stats

                                        Interpolating Splines
                                         插值样条

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Perform cubic (or Hermite) spline interpolation of given data points, returning either a list of points obtained by the interpolation or a function performing the interpolation.
执行立方米(或厄米)给定的数据点样条插值,返回通过插值或函数进行插值获得的积分列表。


用法----------Usage----------


splinefun(x, y = NULL,
          method = c("fmm", "periodic", "natural", "monoH.FC"),
          ties = mean)

spline(x, y = NULL, n = 3*length(x), method = "fmm",
       xmin = min(x), xmax = max(x), xout, ties = mean)

splinefunH(x, y, m)



参数----------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.


参数:m
(for splinefunH()): vector of slopes m[i] at the points (x[i],y[i]); these together determine the Hermite “spline” which is piecewise cubic, (only) once differentiable continuously.
(为splinefunH()):斜坡向量m[i]点(x[i],y[i]);这些共同确定的“曲线”厄米是分段立方米,(只),一次可微连续。


参数:method
specifies the type of spline to be used.  Possible values are "fmm", "natural", "periodic" and "monoH.FC".
指定要使用花键的类型。可能的值是"fmm","natural","periodic"和"monoH.FC"。


参数:n
if xout is left unspecified, interpolation takes place at n equally spaced points spanning the interval [xmin, xmax].
如果xout未指定,插值在n跨越间隔等距点[xmin,xmax]。


参数:xmin, xmax
left-hand and right-hand endpoint of the interpolation interval (when xout is unspecified).
左手和右手的端点插值间隔(当xout是不确定的)。


参数:xout
an optional set of values specifying where interpolation is to take place.
值指定插值发生的一组可选。


参数: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 one complete (x, y) pair is required. If method = "fmm", the spline used is that of Forsythe, Malcolm and Moler (an exact cubic is fitted through the four points at each end of the data, and this is used to determine the end conditions). Natural splines are used when method = "natural", and periodic splines when method = "periodic".
输入可以包含缺少的值被删除,所以至少一个完整的(x, y)对。如果method = "fmm",使用样条线是,科西,马尔科姆和Moler(确切立方米四点通过安装在每个月底的数据,这是用来确定终止条件)。自然样条线时使用method = "natural",并定期样条线时,method = "periodic"。

The new (R 2.8.0) method "monoH.FC" computes a monotone Hermite spline according to the method of Fritsch and Carlson.  It does so by determining slopes such that the Hermite spline, determined by (x[i],y[i],m[i]), is monotone (increasing or decreasing) iff the data are.
新的方法(2.8.0)"monoH.FC"计算单调的Hermite样条根据弗里奇和卡尔森的方法。它通过确定Hermite样条,决定(x[i],y[i],m[i]),是单调的(增加或减少),当且仅当数据斜坡。

These interpolation splines can also be used for extrapolation, that is prediction at points outside the range of x.  Extrapolation makes little sense for method = "fmm"; for natural splines it is linear using the slope of the interpolating curve at the nearest data point.
这些插值样条,也可用于推断,这是在外x范围内点的预测。推断method = "fmm"意义不大;自然样条,它是线性的使用在最近的数据点插值曲线的斜率。


值----------Value----------

spline returns a list containing components x and y which give the ordinates where interpolation took place and the interpolated values.
spline返回一个列表,其中包含组件x和y给坐标插值了地方和插补值。

splinefun returns a function with formal arguments x and deriv, the latter defaulting to zero.  This function can be used to evaluate the interpolating cubic spline (deriv=0), or its derivatives (deriv=1,2,3) at the points x, where the spline function interpolates the data points originally specified.  This is often more useful than spline.
splinefun返回一个函数的形式参数x和deriv,后者拖欠零。此功能可用于评估三次样条插值(deriv= 0),或其衍生物(deriv= 1,2,3)点x,那里的样条函数插值原先指定的数据点。这往往是比spline更多有用。


参考文献----------References----------

The New S Language. Wadsworth & Brooks/Cole.
Computer Methods for Mathematical Computations.
Monotone piecewise cubic interpolation, SIAM Journal on Numerical Analysis 17, 238–246.

参见----------See Also----------

approx and approxfun for constant and linear interpolation.
approx和approxfun常数和线性插值。

Package splines, especially interpSpline and periodicSpline for interpolation splines. That package also generates spline bases that can be used for regression splines.
包splines,尤其是interpSpline和periodicSpline插值样条。该软件包还可以生成样条回归样条曲线,可用于基地。

smooth.spline for smoothing splines.
smooth.spline平滑样条。


举例----------Examples----------


require(graphics)

op <- par(mfrow = c(2,1), mgp = c(2,.8,0), mar = .1+c(3,3,3,1))
n <- 9
x <- 1:n
y <- rnorm(n)
plot(x, y, main = paste("spline[fun](.) through", n, "points"))
lines(spline(x, y))
lines(spline(x, y, n = 201), col = 2)

y <- (x-6)^2
plot(x, y, main = "spline(.) -- 3 methods")
lines(spline(x, y, n = 201), col = 2)
lines(spline(x, y, n = 201, method = "natural"), col = 3)
lines(spline(x, y, n = 201, method = "periodic"), col = 4)
legend(6,25, c("fmm","natural","periodic"), col=2:4, lty=1)

y <- sin((x-0.5)*pi)
f <- splinefun(x, y)
ls(envir = environment(f))
splinecoef <- get("z", envir = environment(f))
curve(f(x), 1, 10, col = "green", lwd = 1.5)
points(splinecoef, col = "purple", cex = 2)
curve(f(x, deriv=1), 1, 10, col = 2, lwd = 1.5)
curve(f(x, deriv=2), 1, 10, col = 2, lwd = 1.5, n = 401)
curve(f(x, deriv=3), 1, 10, col = 2, lwd = 1.5, n = 401)
par(op)

## Manual spline evaluation --- demo the coefficients :[#手动样条评价---演示系数:]
.x <- splinecoef$x
u <- seq(3,6, by = 0.25)
(ii <- findInterval(u, .x))
dx <- u - .x[ii]
f.u <- with(splinecoef,
            y[ii] + dx*(b[ii] + dx*(c[ii] + dx* d[ii])))
stopifnot(all.equal(f(u), f.u))

## An example with ties (non-unique  x values):[#例如关系(非唯一的x值):]
set.seed(1); x <- round(rnorm(30), 1); y <- sin(pi * x) + rnorm(30)/10
plot(x,y, main="spline(x,y)  when x has ties")
lines(spline(x,y, n= 201), col = 2)
## visualizes the non-unique ones:[#可视化的非唯一的:]
tx <- table(x); mx <- as.numeric(names(tx[tx > 1]))
ry <- matrix(unlist(tapply(y, match(x,mx), range, simplify=FALSE)),
             ncol=2, byrow=TRUE)
segments(mx, ry[,1], mx, ry[,2], col = "blue", lwd = 2)

## An example of  monotone  interpolation[#单调插值的一个例子]
n <- 20
set.seed(11)
x. <- sort(runif(n)) ; y. <- cumsum(abs(rnorm(n)))
plot(x.,y.)
curve(splinefun(x.,y.)(x),                add=TRUE, col=2, n=1001)
curve(splinefun(x.,y., method="mono")(x), add=TRUE, col=3, n=1001)
legend("topleft",
       paste("splinefun( \"", c("fmm", "monoH.CS"), "\" )", sep=''),
       col = 2:3, lty = 1)

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-5-6 07:03 , Processed in 0.020470 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表