- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我从实验中获得了 2 条数据曲线(y1 和 y2)。两条曲线具有相同的 x。
对于每条曲线,它们应该由它们自己的基础数据集来描述。
y1 = a* bd1_y1 + b* bd1_y2 + (1-a-b)* bd1_y3
y2 = a* bd2_y1 + b* bd2_y2 + (1-a-b)* bd2_y3
,在哪里
bd1_y1
, bd1_y2
, 和 bd1_y3
是 y1
的基础集数据 bd2_y1
, bd2_y2
, 和 bd2_y3
是 y2
的基础集数据 a
和 b
是基础数据集的相对贡献(0<a,b<1
),是共享的。
我试过这里发布的方法:https://www.mathworks.com/matlabcentral/answers/1056-nonlinear-fit-to-multiple-data-sets-with-shared-parameters#comment_542407但是经过几天的努力,我仍然不知道如何将基集合并到函数(f0)中,因此无法提取 a 和 b。
我怎样才能适应 y1
和 y2
获得a、b和它们的置信区间?非常感谢您的帮助。
Data:
x = [1 2 3 4 5 6 7 8 9 ];
y1 = [0.4304 0.2249 0.1283 0.0794 0.0484 0.0326 0.0203 0.0125 0.0072];
y2 = [0.2179 0.1699 0.1410 0.1101 0.0871 0.0679 0.0515 0.0385 0.0296];
bd1_y1 = [0.5587 0.2244 0.1023 0.0520 0.0276 0.0155 0.0089 0.0053 0.0033];
bd1_y2 = [0.4580 0.2788 0.1198 0.0642 0.0342 0.0197 0.0115 0.0069 0.0043];
bd1_y3 = [0.3584 0.3102 0.1540 0.0755 0.0440 0.0248 0.0148 0.0091 0.0056];
bd2_y1 = [0.3266 0.1778 0.1255 0.0975 0.0777 0.0612 0.0478 0.0367 0.0281];
bd2_y2 = [0.2985 0.2086 0.1268 0.0939 0.0722 0.0580 0.0470 0.0383 0.0313];
bd2_y3 = [0.2451 0.2221 0.1434 0.0999 0.0775 0.0609 0.0494 0.0406 0.0335];
最佳答案
通常,我尽量避免约束。所以第一步应该是:检查真正的解决方案是否在约束范围内。我将使用 Python 进行编程,但它非常通用,因此将其转换为 Matlab 应该很容易。
import numpy as np
xl = np.arange(9)+1
y1 = np.array([
0.4304, 0.2249, 0.1283, 0.0794, 0.0484, 0.0326, 0.0203, 0.0125, 0.0072
])
y2 = np.array([
0.2179, 0.1699, 0.1410, 0.1101, 0.0871, 0.0679, 0.0515, 0.0385, 0.0296
])
bd1_y1 = np.array([
0.5587, 0.2244, 0.1023, 0.0520, 0.0276, 0.0155, 0.0089, 0.0053, 0.0033
])
bd1_y2 = np.array([
0.4580, 0.2788, 0.1198, 0.0642, 0.0342, 0.0197, 0.0115, 0.0069, 0.0043
])
bd1_y3 = np.array([
0.3584, 0.3102, 0.1540, 0.0755, 0.0440, 0.0248, 0.0148, 0.0091, 0.0056
])
bd2_y1 = np.array([
0.3266, 0.1778, 0.1255, 0.0975, 0.0777, 0.0612, 0.0478, 0.0367, 0.0281
])
bd2_y2 = np.array([
0.2985, 0.2086, 0.1268, 0.0939, 0.0722, 0.0580, 0.0470, 0.0383, 0.0313
])
bd2_y3 = np.array([
0.2451, 0.2221, 0.1434, 0.0999, 0.0775, 0.0609, 0.0494, 0.0406, 0.0335
])
"""
if y = a x1 + b x2 + (1- a - b ) x3 then
y - x3 = a ( x1 - x3 ) + b ( x2 -x3 )
i.e. simple transformation to get a homogeneous linear system
"""
y1k = y1 - bd1_y3
y11k = bd1_y1 - bd1_y3
y12k = bd1_y2 - bd1_y3
y2k = y2 - bd2_y3
y21k = bd2_y1 - bd2_y3
y22k = bd2_y2 - bd2_y3
"""
So we just want to solve a simple linear system
y = a x1 + b x2
with y = (y1,...., yn ) and x1 = ( x11, x12, ..., x1n) etc
handling the two measurements with shared parameters is done by just
adding the according vectors so yp and yq go into
y_tot = ( yp1, ..., ypn, yq1, ...yqn ) and same for the x
The x for the matrix A such we can write the thing as y = A.(a,b)
This is standard linear optimization!
this is done in short in the following (first joining the data sets)
"""
y = np.append( y1k, y2k )
z1 = np.append( y11k, y21k )
z2 = np.append( y12k, y22k )
AT = np.array( [ z1, z2 ] )
A = np.transpose( AT )
U = np.dot( AT, A )
UI = np.linalg.inv( U )
K = np.dot( UI, AT )
v = np.dot( K, y )
a = v[0]
b = v[1]
print( a, b )
"""
in detail this should be done more carefully to avoid singular matrices etc,
e.g. via single value decomposition etc
in a next step it is usually assumed that all measurements share the
same base error s which we calculate
"""
diff = y - a * z1 - b * z2
s2 = np.sum( diff**2 ) / ( len( diff ) - 1 )
"""
The covariance matrix now is calculated via error propagation,
namely like s_a = s * sqrt( sum_i ( da / dyi )^2 ), which gives the classical
s^2 * K KT
"""
cov = s2 * np.dot( K, np.transpose( K ) )
print( cov )
"""
the error of a is (and be accordingly)
"""
sa = np.sqrt( cov[0,0] )
sb = np.sqrt( cov[1,1] )
print( sa, sb )
这段代码已经连接了两个数据集,可以很容易地扩展到 n 个数据集。最终的解决方案如下所示:
上图:原始数据。目标是蓝色和三个基地数据集分别为黄色、绿色和红色。下图是蓝色目标和黄色最适合无约束
有了解决方案
>> 1.9712440231598143 -3.163257723318949
所以这不在界限之内。实际上,a > 1
和 b < 0
.所以我们知道解决方案位于边界上。在(a,b)
- 空间,在右侧或底部。真正线性问题中的最小二乘最小化给出真正的抛物线形状,因此只有一个解,没有局部最小值。
现在我们可以在某种程度上强制解决边界上的问题,而不是尝试解决约束问题。
"""
We just set on parameter to the according boundary value
and just solve as before. Here a matrix formalism is a small
overkill, but for consistency a good way of writing it.
"""
"""
case 1: b = 0
"""
AT = np.array( [ b1all ] )
A = np.transpose( AT )
U = np.dot( AT, A )
UI = np.linalg.inv( U )
K = np.dot( UI, AT )
v = np.dot( K, yall )
aopt1 = v[0]
diff = yall - aopt1 * b1all - 0 * b2all
s2 = np.sum( diff**2 ) / ( len( diff ) - 1 )
cov = s2 *np.dot( K, np.transpose( K ) )
print( aopt1 )
print( cov, np.sqrt(cov[0,0]) )
"""
case 2: a=1
"""
ymod = yall - b1all
AT = np.array( [ b2all ] )
A = np.transpose( AT )
U = np.dot( AT, A )
UI = np.linalg.inv( U )
K = np.dot( UI, AT )
v = np.dot( K, ymod )
bopt1 = v[0]
diff = ymod - bopt1 * b2all
s2 = np.sum( diff**2 ) / ( len( diff ) - 1 )
cov = s2 *np.dot( K, np.transpose( K ) )
print( bopt1 )
print( cov, np.sqrt(cov[0,0]) )
给出 a
>> 0.3815249997379142
>> [[0.00807797]] 0.08987750010601071
和b
>> -1.2997646861507886
>> [[0.01736744]] 0.13178558294218914
所以在a=1
为 b
的最佳值划线再次不在约束范围内,而 b = 0
a
的最小值.
从图形角度来看,这看起来像
卡方曲面作为密度图。边界以红色显示。通过椭圆轮廓线可以看到真正的最小值。 a=1
上的局部最小值和 b=0
显示为蓝点
这里可以看到卡方曲面的抛物线最小值。如果这必须应用于许多不同的数据集,那么自动化决策应该很容易。计算速度很快,因为一切都是线性的,可以一次性计算出来。如果真正的解决方案在边界之外,并且有一个边界具有局部最小值,则会有第二个,但这是在另一侧,因此不相关。最后,对于每个边界,最小值不满足约束条件。然后解决方案是相应的角落。在某种程度上,这个简单的案例允许手动执行步骤,否则将执行不等式约束算法(适用于更复杂的情况)。
关于matlab - 使用Matlab通过全局拟合找出基础数据集的相对贡献?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66052010/
找出/计算符号的宽度 panel.add(textfield,BorderLayout.SOUTH); system.out.println(textfield.getWidth()); System
嘿,所以我正在制作一个因式分解程序,我想知道是否有人可以给我任何想法,让我知道如何找到一个有效的方法来找到两个数字乘以指定数字的倍数,以及添加到指定数字。 例如我可能有 (a)(b) = 6 a +
我以以下方式将 GWT 方法导出到 native javascript: public class FaceBookGalleryEntryPoint implements EntryPoint {
通常,当您在 Web 上找到 Silverlight 代码示例时,它可能只包含一段代码,而不是使其工作所需的完整代码集。当我试图确定在 xaml 文件顶部使用什么命名空间和/或程序集声明时,这让我感到
我对 Dojo 工具包有点陌生。有些问题我想得到启发(我用谷歌搜索,但没有得到任何合适且令人满意的答案) 我已经在运行的应用程序(由另一个软件开发人员开发)中有一个 dojo.js(也许是下载的未压缩
这个问题在这里已经有了答案: 关闭 11 年前。 Possible Duplicate: How to detect which row [ tr ] is clicked? 我有一个这样的表:
我目前正在尝试找出特定应用程序使用的数据保护类别。 我的第一个方法是使用未加密的 iTunes 备份来确定所使用的保护类别。我用过this提取备份。但现在我要陷入困境了。 此外,我不太确定 iTune
我有一个 NSRangeException 错误,该错误并不总是发生(尤其是在调试时)。它是随机出现的,我无法弄清楚它来自哪里。我有很多数组操作,因此很难以这种方式消除它。 我的问题是我是否可以从调试
我有一个控制台程序,它链接到 Mac 上的 Foundation 框架。如何找到可执行文件所在的文件夹? 最佳答案 即使该工具不在 bundle 中,您仍然可以使用一些 NSBundle 方法。例如:
简单的问题是:如何找出 Cocoa 应用程序中可执行文件的位置。 请记住,在许多类 Unix 操作系统中,人们使用 PATH 环境来为其可执行文件分配首选位置,特别是当他们的系统中有同一应用程序的多个
如何找出 TGridPanel 内控件的位置(行和列索引)?我想对按钮数量使用常见的 OnClick 事件,并且需要知道按钮的 X、Y 位置。 我使用的是 Delphi 2007。 最佳答案 不幸的是
我试图找到一种方法来确定 .NET 应用程序中任意文件夹中的总磁盘空间和可用磁盘空间。文件夹中的“总磁盘空间”和“可用磁盘空间”是指如果您对其执行“dir”命令,该文件夹将报告的总磁盘空间和可用磁盘空
我希望能够通过 shell 脚本判断任何 POSIX 系统上是否存在命令。 在 Linux 上,我可以执行以下操作: if which ; then ...snip... fi 但是,Solar
如何找到不同 Haskell 函数的复杂性(以 big-O 表示)? 例如, subsequences 的复杂度是多少? ? 最佳答案 您只能通过查看代码来计算函数的确切复杂度。但是,您可以使用 cr
我试图找出我的对象占用了多少内存来查看有多少对象最终出现在 Large Object Heap 上。 (超过 85,000 字节)。 是否像为每个对象添加 4(表示 int)、添加 8(表示 long
一旦我在 Vim 中加载任何文件,它就会尝试检测该文件,并在可能的情况下用颜色突出显示它。 我想知道一个 Vim 命令,它会告诉我 Vim 认为哪个 ftplugin 或文件类型插件/文件类型会突出显
是否有可能找出 querySelector 的哪一部分与 DOM 中的特定元素匹配? 假设您有以下查询: 'h1,h2,h3,h4.custom-bg,div' 如果您使用 document.quer
我遇到一个问题,用户设置的区域设置(德语)与安装的语言 Windows(英语)不同。有没有办法发现安装的 Windows 语言与用户设置的区域设置?我应该注意的问题是我正在创建共享,并且根据区域设置设
我正在写入应用程序中的文件。我想找到该文件以检查该文件是否已正确写入(以便我可以通过 Web View 访问该文件)。这是我用来编写文件的代码: try { FileOutputStream
我有一个从 JSON 文件填充的 HashMap。键值对中的值可以是两种不同的类型 - 字符串或其他键值对。 例如: HashMap hashMap = new Map(); JSON 文件看起来有点
我是一名优秀的程序员,十分优秀!