- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我知道平滑参数(lambda)对于拟合平滑样条曲线非常重要,但是我在这里没有看到有关如何选择合理的lambda(spar =?)的任何文章,有人告诉我spar通常在0到1的范围内。当使用smooth.spline()时,谁能分享您的经验?谢谢。
smooth.spline(x, y = NULL, w = NULL, df, spar = NULL,
cv = FALSE, all.knots = FALSE, nknots = NULL,
keep.data = TRUE, df.offset = 0, penalty = 1,
control.spar = list(), tol = 1e-6 * IQR(x))
最佳答案
agstudy提供了一种可视的方式来选择spar
。我记得我从线性模型类中学到的(但不完全是)是使用交叉验证来选择“最佳” spar
。这是从agstudy借来的一个玩具示例:
x = seq(1:18)
y = c(1:3,5,4,7:3,2*(2:5),rep(10,4))
splineres <- function(spar){
res <- rep(0, length(x))
for (i in 1:length(x)){
mod <- smooth.spline(x[-i], y[-i], spar = spar)
res[i] <- predict(mod, x[i])$y - y[i]
}
return(sum(res^2))
}
spars <- seq(0, 1.5, by = 0.001)
ss <- rep(0, length(spars))
for (i in 1:length(spars)){
ss[i] <- splineres(spars[i])
}
plot(spars, ss, 'l', xlab = 'spar', ylab = 'Cross Validation Residual Sum of Squares' , main = 'CV RSS vs Spar')
spars[which.min(ss)]
R > spars[which.min(ss)]
[1] 0.381
cv=T
中指定
smooth.spline
:
R > xyspline <- smooth.spline(x, y, cv=T)
R > xyspline$spar
[1] 0.3881
关于r - 如何为smooth.spline()选择平滑参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14929268/
我有几个数据点似乎适合于通过它们拟合样条曲线。当我这样做时,我得到了一个非常坎bump的拟合,例如过度拟合,这不是我所理解的平滑。 是否有特殊的选项/参数来恢复像here这样的非常平滑的样条曲线的功能
编辑:我找到了一个 jQuery 解决方案! https://codepen.io/chriscoyier/pen/dpBMVP这个确实适用于 iOS。我想 jQuery 桥接浏览器支持问题的日子还没
我正在阅读世界各国的一些数据,并正在使用 Google 的可视化小工具,尤其是 map visualizations 。问题是,美国总是走在前面。虽然大多数国家/地区的值在 1 到 50 之间,但美国
我在我的 friend Google 上搜索了一些代码来进行平滑滚动并找到了这个:Smooth vertical scrolling on mouse wheel in vanilla javascr
在过去的一个半星期里,我一直在使用 Java 和 Swing 从头开始编写游戏。到目前为止,游戏运行一切顺利,除了一件事:跳跃。我正在尝试实现抛物线跳跃,以便玩家不只是向上传送一点点。相反,我希望
我将数据从 Cursor 加载到 ListView ,但我的 ListView 并没有真正显示“平滑”。当我在 ListView 的 scollbar 上上下拖动时,数据会发生变化。有些项目在我的列表
谁能给我一些关于如何生成“平滑”随机数的提示?这就是我所说的平滑: 随机数应在游戏中使用,例如风向和强度(有没有人记得好老的“蠕虫”?)。当然,每隔一秒左右为这些值设置随机数看起来会非常不稳定。我宁愿
这是我第一次在这里写文章。我对 JQuery 动画有一些问题:当持续时间非常慢(例如 10000)时, Action 不够平滑。我的 div 需要一个“自然”的运动。有人知道我的问题的解决方案吗?或者
我有一个数组: array = [10, 10, 10, 10, 10] 我想遍历这个数组,以便它得到一个基于整数的“斜率”。所以如果整数是 2,结果将是: array = [0, 5, 10, 5,
我正在构建一个股票代码,我正在尝试使用 Smooth Div Scroll插件,但我无法让它与动态创建的段落标签一起使用。它不是创建滚动的水平列表,而是将 P 标签垂直转储到页面上。如果段落标签是静态
有没有办法在平滑滚动(参见示例)结束时获得回调? 我唯一能想到的就是观察 scroll 的缺失事件,但没有办法将它们与 anchor 点击联系起来 - 您如何将它们与只是自己滚动页面的用户区分开来?
问题背景: 我正在 ASP.NET MVC 项目中使用 Twitter Bootstrap 3 开发一个单页网站。 问题: 我目前正在尝试实现“平滑滚动”,该滚动应该通过从导航栏下拉列表中单击来滚动到
平滑滚动对我来说一直感觉非常缓慢和滞后(我希望一切都快快),但幸运的是可以在浏览器设置中禁用它。但是,我注意到越来越多的网页使用 javascript 强制平滑滚动,无论我的设置如何(例如 this
我有一个由 div 制成的小 table ,上面有一个“添加新”按钮来添加新行,每行上有一个 x 按钮来删除该行。表格有一个最大高度,一旦达到这个高度就会在添加新行时滚动到底部。我已经在 css 中将
我使用了 CSS TRICKS 的 Smooth Scroll Plugin,它工作得很好,但只有 2 个 ancoher 链接,而不是另一个链接,请在此处查看演示, LIVE DEMO 它对行业和定
我尝试为 Google 地球 (c++) 编写自己的应用程序界面。我正在使用 Earthlib 来控制相机 (EARTHLib::ICameraInfoGE)。该接口(interface)允许控制相机
如果我想编写一个函数(可能也是一个类),它从不可变的查找表(调用构造函数时固定)返回线性“平滑”数据,如下所示: 例如func(5.0) == 0.5。 存储查找表的最佳方式是什么? 我正在考虑使用两
根据 Chromecast 开发人员页面,Chromecast 支持 SmoothStreaming 容器,我相信它使用带有 .ismv 扩展名的视频块。我在播放这些视频文件时遇到问题。 如果我没记错
原始问题 我想平滑我的解释变量,例如车辆的“速度”数据,然后使用此平滑后的值。我搜索了很多东西,却没有发现直接答案。 我知道如何计算内核密度估计(density()或KernSmooth::bkde(
我尝试了几种不同的开箱即用选项来平滑我的数据中的一个步骤,但还没有完全找到我所追求的。在下面粘贴一个小的可复制示例。正如下面的屏幕截图中突出显示的,是否有一个 R 函数可以平滑步骤,类似于 smoot
我是一名优秀的程序员,十分优秀!