- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
给定 y 轴 (s) 上的缩放和 x 轴 (t) 上的平移参数,当目的是最大化曲线叠加(而不是最小化距离)时,如何缩放和对齐两条不重合的曲线?
正如 @DWin 所指出的,这可能会被重新命名为“如何使用 R 完美地玩俄罗斯方 block ”,尽管它的应用范围远远超出了赢得俄罗斯方 block 游戏的范围。
这个问题的一个变体可能涉及任意数量的刚体变换(旋转、平移和缩放)。
给定曲线 1
curve1<-data.frame(x=c(1,1,2,2,3),
y=c(9,6,6,3,3))
with(curve1, plot(x=x, y=y, type="l", xlim=c(0,10), ylim=c(0,10)))
和曲线 2
curve2<-data.frame(x=c(4,5,5,6,6,7),
y=c(2,2,1,1,2,3))
with(curve2, plot(x=x, y=y, type="l", xlim=c(0,10), ylim=c(0,10)))
我希望找到使两条曲线之间叠加最大化的 s 和 t。
理想情况下,该方法应在 R 中使用 optim。
在这个虚构的示例中,t=3 且 s=1/3,因此
t=3
s=1/3
with(curve2, plot(x=x, y=y, type="l", xlim=c(0,10), ylim=c(0,10)))
with(curve1, lines(x=x+t, y=y*s, col="red"))
请注意,为了获得这样的拟合,可以达成共识的区域必须比无法叠加的区域具有更高的参数化权重,并且共识区域越大,权重越高。
我一直在探索的路线:
使用最大似然法的奖励积分(假设误差呈正态分布)。
最佳答案
当 curve1 在 y 轴上按因子“tfac”缩放并在 x 轴上移动量“s”时,这将返回点之间的距离:
as.matrix( dist( rbind(as.matrix(curve2),
( matrix(c(rep(s, 5), rep(1,5)), ncol=2) + # x-shift matrix
as.matrix(curve1) ) %*%
matrix(c( 1, 0, 0, tfac),ncol=2) ) ) # the y-scaling matrix
)[
# better not to use 't' as a variable name
-(1:5), -(6:11)] # easier to return the relevant distances when in matrix
将其放入要最小化的函数中应该是一件简单的事情:
dfunc <- function(C1, C2, s, tfac) { sum( .... ) }
我不确定这会返回您期望的结果,因为您暗示的目标函数可能不是距离之和。您可能需要转向整数编程方法。优化 CRAN 任务 View 将是在 R 中查找这些方法的好地方。我想如果出现此问题,另一种选择可能是将“s”值舍入并仅缩放到最接近的 2 次方。
dfunc <- function(param, D1=curve1, D2=curve2) {
sum( as.matrix(dist(
rbind(as.matrix(D2),
( matrix(c(rep(param[1], 5), rep(1,5)), ncol=2) +
as.matrix(D1) ) %*%
matrix(c(1,0,0,param[2]),ncol=2) ) ) )[-(1:5), -(6:11)])}
optim(c(1,1), dfunc)
#$par
$[1] 3.3733977 0.2243866
# trimmed output
使用这些值可以获得以下叠加:
因此,我可能会尝试 s=3,tfac=0.25。 (回想起来,我发现我按照您的要求交换了 t 和 s 的角色。抱歉。)
关于r - 玩完美俄罗斯方 block : how to align and scale two curves using scaling and translation?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10826625/
我正在尝试创建一个数据库来处理我在 Play 中的任务!框架。 这是我所拥有的: 在build.sbt中: libraryDependencies ++= Seq( jdbc, cache,
在我的游戏中定义一个表单!当编译器吐出这个奇怪的错误时 Controller :重载方法值映射与替代:...[一堆废话]...Error occurred in an application invo
我的应用程序有问题,@Max约束注释。 我的 Controller 方法定义如下: public static void save(@Required @Max(255) String content
我想创建一个像这样的标签: #{some_tag entity:user, field:'name'} 并期望它通过使用如下表达式生成带有用户名的输出: ${_entity._field} 我知道这行
我创建了一些 Model 对象来代表一家拥有多个客户的公司,以及一个由公司和客户组合以及多个发票行组成的发票对象。我创建了以下模型对象: @Entity public class Company ex
Playframework 现在是 typesafe-stack 的一部分。 那么,如果我要使用像主要语言一样的 Scala ,我现在应该下载什么? TypsafeStack 还是 PlayFrame
在玩!如果你这样称呼: void method() { User u = User(); u.name = "bob"; u.save(); while(true){/* endless loop *
我正在 Play 中构建一个应用程序!包含大量我想跟踪更改的数据的框架。在企业解决方案中,我可能会使用数据库触发器将更改复制到历史表中以跟踪这些更改。我不熟悉 Play!/JPA 中的类似范例,但也许
我一直在学习JavaScript技能,但是遇到一个问题,当单击此处是我的代码时,音频没有被播放。 Your browser does no
我想实现在某些模型保存后在表中插入一行的行为。我当前的解决方案简而言之是:(这只是我的代码示例,因此请不要评论数据库或描述符模型的正确性)。 我有一个监听器,用于在更新/插入实体上插入行为行 Desc
如何使我的模型类字段独一无二?例如。如果已经登录,我想为用户显示正确的消息。我必须自己编写验证检查并使用它,或者可以使用 JPA @UniqueConstraint? 最佳答案 我是这样做的: @En
我使用的是 Play 1.2.1。我想对我的用户密码进行哈希处理。我认为 Crypto.passwordHash 会很好,但事实并非如此。 passwordHash 文档说它返回 MD5 密码哈希值。
我一直在研究戏剧!框架模块并希望扩展它,添加一些功能。我发现了一个从Enhancer(play.classloading.enhancers.Enhancer)扩展的类,但不明白为什么Play!采用了
我使用的是 Play Framework 1.2.5。我有几个与 NAme 和 Age 字段相关的验证。年龄验证无法正常工作。即使年龄大于 18 岁,我也会收到错误消息。 下面是action方法中的验
我使用的是 Play Framework 1.2.5。两者有什么区别: @{Application.render()} 和 @Application.render() 第一个最好用在表单 Action
我是新来的!我被一些总是有错误的表格所困扰。即使所有字段都已填写,我也无法弄清楚问题是什么。 路线 GET /products/ controllers.Pr
我显示可编辑的数据库表行的列表。我想允许用户编辑显示表中的数据并同时保存所有更新。我应该如何取回 Controller 的更新列表? 最佳答案 由于 Play 可以绑定(bind)到 POJO,也可以
那么,假设我从 Controller 异步启动一个作业,然后渲染一些模板。 MyJob job = new MyJob(); job.doJob(); render(); 我的工作看起来像: 导入 p
当前使用的 Play Framework 为 2.0.4。当我尝试使用此命令升级到 2.6.21 时: addSbtPlugin("com.typesafe.play"% "sbt-plugin"%
我目前正在与 Play 合作!框架和看来日志记录只适用于游戏!仅但对于具有 LOGGER 初始化的类不起作用。 这是 logback.xml ${application.hom
我是一名优秀的程序员,十分优秀!