PHP估算函数
我正在尝试根据数字数组(如 $numbers)计算数字系列中的值 $x。
例如:
$numbers = array(1=>1000,2=>600,3=>500,4=>450,5=>425,6=>405,7=>400,8=>396);
function estimateNumber($x) {
// function to estimate number $x in $numbers data set
}
统计上最准确的方法是什么?
I am trying to calculate value $x in a number series based on an array of numbers (as $numbers).
Ex:
$numbers = array(1=>1000,2=>600,3=>500,4=>450,5=>425,6=>405,7=>400,8=>396);
function estimateNumber($x) {
// function to estimate number $x in $numbers data set
}
What would be the most statistically accurate method?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不存在单一的“统计上最准确的方法”。这取决于您的估计值以及之前观察到的值。根据您现有的一组值,它似乎呈指数下降,并且如您所见,到第 7 个和第 8 个值时,它已经达到分别仅下降 5 和 4 的点。您可以预期该值会进一步减少 3、2 和 1,之后它将几乎保持不变,仅在小数位上发生一点变化。
这将是一个公平的近似值:
There is no single "most statistically accurate method". It depends on what you are estimating as well as previously observed values. Going by your existing set of values, it seems to be exponentially decreasing, and as you can see, by the 7th and 8th values, it's already reached a point where it decreases only by 5 and 4 respectively. You can expect this to further reduce by 3, 2 and 1, after which it would become almost constant, only changing a little in the decimal places.
This would be a fair approximation:
您尝试做的是数学的一个大分支,称为插值。声称一种方式比另一种方式“统计上更准确”可能会引发宗教战争。这完全取决于您要插入的数据类型。
线性插值将是最简单的。
What you're attempting to do is a large branch of mathematics called interpolation. Claiming one way is more "statistically accurate" than the other will probably spark religious wars. It all depends on what kind of data you're trying to interpolate.
Linear interpolation will be the most straightforward.
您需要决定是要拟合直线还是 n 阶多项式。也许可以尝试 Excel 中的一些示例来了解您需要什么。
You need to decide if you want to fit a straight line or an n-th order polynomial. Maybe try some examples in Excel to give you an idea of which you need.