如何求解 p = aw + 形式的方程bx +赛+ dz 我哪里有几千个ae数据集?

发布于 2024-10-05 16:10:08 字数 202 浏览 0 评论 0原文

我有数千个 (p, w, x, y, z) 数据集,并且我非常确定它们符合 p= aw + bx + cy + dz 形式的方程, p 以某种方式四舍五入。

给定我拥有的变量和结果的所有数据集,我想编写一个程序来求解常量 a、b、c 和 d。或者,如果有软件可以做到这一点,那就太好了。有什么建议或任何我可以用来做进一步研究的谷歌关键字吗?

I have thousands of data sets of (p, w, x, y, z), and I'm pretty sure that they fit an equation of the form p= aw + bx + cy + dz, with p rounded up in some way.

I'd like to write a program to solve for the constants a, b, c, and d, given all the data sets for the variables and result that I have. Alternatively, if there is software that can already do this, that would be great. Any suggestions, or any Google keywords I can use to do further research?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

旧瑾黎汐 2024-10-12 16:10:09

请注意,如果这些点完全符合方程,那么您只需要四个数据来确定参数,而不是“千”。剩下的点要么适合方程(因此是多余的),要么不能适合方程(即你的问题是不可能的)

如果相反,你正在寻找的拟合不一定是完美的,你需要的是找到参数a、b、c、d 是最佳拟合(即最小化平方误差),那么您需要的是线性回归。

请注意,定义数据点之一的每个方程都可以写成

Ax = B 的

形式,其中 A 是 4 个值的行向量,x 是 4 个值的列向量。
因此,

  • 向量 A 总结了你的写作中由元组 (a, b, c, d) 携带的信息,
  • 向量 x 总结了你写作中的元组 (w, x, y, z)。
  • 那么,B 是一个标量。

此时,您可以谷歌搜索“线性回归”并应用知识。 :)
有几个软件包可以做到这一点,例如 matlab、octave,但甚至可能 Excel 也可以做到。 :)

Notice that, if the points fit the equation perfectly, then you only need four data to determine the parameters and not "thousand". The remaining points either fit the equations (hence are redundant) or cannot be made to fit the equation (i.e. your problem is impossible)

If instead the fit that you're looking for is not necessarily perfect and what you need is to find the parameters a,b,c,d that are the optimal fit (i.e. minimize square errors), then what you need is a linear regression.

Please notice that each of the equations that define one of your datapoint can be written in the form

Ax = B

where A are row-vectors of 4 values and x is a column-vector of 4 values.
For this reason,

  • the vector A summarizes the info that in your writing is carried by the tuple (a, b, c, d)
  • the vector x summarizes the info that in your writing is carried by the tuple (w, x, y, z).
  • B is, then, a scalar.

At this point you may google for "linear regression" and apply the knowledge. :)
There are several software packages to do this, like matlab, octave, but probably even Excel can do it. :)

顾北清歌寒 2024-10-12 16:10:09

您正在寻找的是联立线性方程求解器。我建议用您选择的语言搜索实现。

What you are looking for is a simultaneous linear equation solver. I would recommend googling for an implementation in the language of your choice.

勿忘心安 2024-10-12 16:10:09

如果我理解你的问题,在线性代数中,当你有一个由 n 个未知数组成的线性系统时,你至少需要 n 个方程来解决每个未知数。

如果您有 m 个方程和 n 个未知数且 m < n,你将有 (nm) 个自由变量。

如果m>1 n,你可能有一个不可能的系统,这取决于系统本身。

因此,有了数千个 (p, w, x, y, z),您就可以拥有另外数千(甚至数千)个解决方案组合。

希望有帮助。

If I understood your question, in linear algebra, when you have a linear system consisting of n unknowns, you need at least n equations to solve it for every unknown.

If you have m equations and n unknowns and m < n, you'll have (n-m) free variables.

If m > n, you might have an impossible system, depending the system itself.

So, with thousands of (p, w, x, y, z)s, you can have another thousands (or even thousands of thousands) of solution combinations.

Hope it helps.

情绪少女 2024-10-12 16:10:09

如果您有数千个数据点 q i = (pi, wi, xi, yi, zi), i = 1..n,并且只有 4 个未知数 (a,b,c,d),那么你就有了一个过度约束的线性系统,它不太可能有一个唯一解决方案。

一般来说,您需要解决一个看起来像这样的系统

[ w1 x1 y1 d1 ] [ a ]        [ p1 ]
[ w2 x2 y2 d2 ] [ b ]     =  [ p2 ]
[ .           ] [ c ]        [ p3 ]
[ .           ] [ d ]        [ .  ]
[ .           ]    4 x 1     [ .  ]
[ wn xn yn dn ]              [ .  ]
                             [ pn ] 
     n x 4                       n x 1

在这种情况下,您需要获得解决方案的“最佳近似”,因为不会有唯一的解决方案。最小二乘近似就是一个例子。

If you have thousands of data points q i = (pi, wi, xi, yi, zi), i = 1..n, and only 4 unknowns (a,b,c,d), then you have an overconstrained linear system, which is unlikely to have a unique solution.

In general, you need to solve a system that looks like

[ w1 x1 y1 d1 ] [ a ]        [ p1 ]
[ w2 x2 y2 d2 ] [ b ]     =  [ p2 ]
[ .           ] [ c ]        [ p3 ]
[ .           ] [ d ]        [ .  ]
[ .           ]    4 x 1     [ .  ]
[ wn xn yn dn ]              [ .  ]
                             [ pn ] 
     n x 4                       n x 1

In such a case you need to get a "best approximation" to the solution, because there won't be a unique one. An example of that would be a least squares approximation.

才能让你更想念 2024-10-12 16:10:09

感谢您的回复。这让我开始。

我得到的 p 值是四舍五入的。我认为,在我试图恢复的原始公式中,a、b、c 和 d 值是具有整数分子和分母的分数。所以我的想法是,我需要四组以上的值来帮助过滤舍入,然后当我接近可能的值时,我将尝试找出最有可能相当于十进制值的小数我得到了,用最小的积分分母。这让我问,是否有一种算法/程序可以将小数转换为指定误差范围内最简单的分数?

Thanks for the responses. This gets me started.

The p values that I have are rounded. And I think that the a, b, c, and d values are, in the original formula that I am trying to recover, fractions with integral numerators and denominators. So what I'm thinking is that I need more than four sets of values to help filter out the rounding, and then as I close in on the probable values, I'll try to figure out the mostly likely fractional equivalent to the decimal values I get, with the lowest integral denominators. Which leads me to ask, is there an algorithm/program to convert decimals to the simplest possible fractions within a specified range of error?

怪异←思 2024-10-12 16:10:09

我建议通过线性回归来解决这个问题。

基本上,线性回归背后的想法是,您有一个自变量 (X) 矩阵,并且您希望使用它们来预测因变量 y 的向量。

对于这个问题有一个封闭形式的解——称为“正规方程”。

您可以用任何语言执行线性回归。您甚至可以在 Excel 中完成此操作。

以下教程介绍了如何在 Octave 中执行线性回归:http://www .lauradhamilton.com/tutorial-linear-regression-with-octave

I would suggest solving this via linear regression.

Basically, the idea behind linear regression is that you have a matrix of independent variables (X) and you want to use them to predict a vector of dependent variables y.

There is a closed-form solution for this -- called the "normal equation."

You can perform linear regression in any language. You can even do it in Excel.

Here is a tutorial that describes how to perform linear regression in Octave: http://www.lauradhamilton.com/tutorial-linear-regression-with-octave

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文