在 Excel 中插入数据点

发布于 2024-07-25 09:15:20 字数 781 浏览 5 评论 0原文

我确信这是其他人之前已经解决过很多次的问题。

一群人将进行测量(确切地说是家庭能源使用情况)。 他们都会在不同的时间和不同的时间间隔这样做。

因此,我将从每个人那里得到一组 {date, value} 对,其中缺少日期。

我需要的是一组完整的 {date, value} 对,其中对于范围内的每个日期,都有一个值已知(测量或计算)。 我希望一个简单的线性插值就足以满足这个项目的需要。

如果我假设它必须在 Excel 中完成。 在这样的数据集中进行插值的最佳方法是什么(这样我每天都有一个值)?

谢谢。

注意:当这些数据集完成后,我将确定斜率(即每天的使用情况),然后我们可以开始进行逐户比较。

附加信息 在最初的一些建议之后: 我不想手动找出测量集中的孔在哪里(太多不完整的测量集!!)。 我正在寻找(现有的)自动为我做这件事的东西。 因此,如果我的输入是

{2009-06-01,  10}
{2009-06-03,  20}
{2009-06-06, 110}

那么我希望自动得到

{2009-06-01,  10}
{2009-06-02,  15}
{2009-06-03,  20}
{2009-06-04,  50}
{2009-06-05,  80}
{2009-06-06, 110}

是的,我可以编写执行此操作的软件。 我只是希望有人已经有一个“准备运行”软件(Excel)功能来解决这个(相当通用的)问题。

I'm sure this is the kind of problem other have solved many times before.

A group of people are going to do measurements (Home energy usage to be exact).
All of them will do that at different times and in different intervals.

So what I'll get from each person is a set of {date, value} pairs where there are dates missing in the set.

What I need is a complete set of {date, value} pairs where for each date withing the range a value is known (either measured or calculated).
I expect that a simple linear interpolation would suffice for this project.

If I assume that it must be done in Excel.
What is the best way to interpolate in such a dataset (so I have a value for every day) ?

Thanks.

NOTE: When these datasets are complete I'll determine the slope (i.e. usage per day) and from that we can start doing home-to-home comparisons.

ADDITIONAL INFO After first few suggestions:
I do not want to manually figure out where the holes are in my measurement set (too many incomplete measurement sets!!).
I'm looking for something (existing) automatic to do that for me.
So if my input is

{2009-06-01,  10}
{2009-06-03,  20}
{2009-06-06, 110}

Then I expect to automatically get

{2009-06-01,  10}
{2009-06-02,  15}
{2009-06-03,  20}
{2009-06-04,  50}
{2009-06-05,  80}
{2009-06-06, 110}

Yes, I can write software that does this. I am just hoping that someone already has a "ready to run" software (Excel) feature for this (rather generic) problem.

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

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

发布评论

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

评论(7

情徒 2024-08-01 09:15:20

我遇到了这个问题,并且不愿意使用加载项,因为这使得与未安装加载项的人共享工作表变得困难。

我的同事设计了一个相对紧凑的干净公式(以使用一点魔法为代价)。

注意事项:

  • 公式的工作原理:

    • 使用 MATCH 函数在 inputs 范围中查找要搜索的值之前的行(例如 3 是 3.5 之前的值)
    • 使用 OFFSET 选择该线和下一条线的正方形(浅紫色)
    • 使用FORECAST仅使用这两个点构建线性插值,并获取结果
  • 这个公式不能做外推; 确保您的搜索值位于端点之间(我在下面的示例中通过使用极值来做到这一点)。

不确定这对人们来说是否太复杂; 但它的优点是非常便携(并且比许多替代解决方案更简单)。

如果要复制粘贴公式,则为:

=FORECAST(F3,OFFSET(inputs,MATCH(F3,inputs)-1,1,2,1),OFFSET(inputs,MATCH(F3,inputs) )-1,0,2,1

输入是命名范围)

I came across this and was reluctant to use an add-in because it makes it tough to share the sheet with people who don't have the add-in installed.

My officemate designed a clean formula that is relatively compact (at the expensive of using a bit of magic).

Things to note:

  • The formula works by:

    • using the MATCH function to find the row in the inputs range just before the value being searched for (e.g. 3 is the value just before 3.5)
    • using OFFSETs to select the square of that line and the next (in light purple)
    • using FORECAST to build a linear interpolation using just those two points, and getting the result
  • This formula cannot do extrapolations; make sure that your search value is between the endpoints (I do this in the example below by having extreme values).

Not sure if this is too complicated for folks; but it had the benefit of being very portable (and simpler than many alternate solutions).

If you want to copy-paste the formula, it is:

=FORECAST(F3,OFFSET(inputs,MATCH(F3,inputs)-1,1,2,1),OFFSET(inputs,MATCH(F3,inputs)-1,0,2,1

(inputs being a named range)

甩你一脸翔 2024-08-01 09:15:20

一种很好的图形方式来查看插值结果的拟合程度:

获取日期、值对并使用 Excel 中的 XY 图表(而不是折线图)将它们绘制成图表。 右键单击图表上的结果线,然后单击“添加趋势线”。 有许多不同的选项可以选择使用哪种类型的曲线拟合。 然后您可以转到新创建的趋势线的属性并显示方程和 R 平方值。

确保在设置趋势线方程标签格式时,将数字格式设置为高精度,以便显示方程常数的所有有效数字。

A nice graphical way to see how well your interpolated results fit:

Take your date,value pairs and graph them using the XY chart in Excel (not the Line chart). Right-click on the resulting line on the graph and click 'Add trendline'. There are lots of different options to choose which type of curve fitting is used. Then you can go to the properties of the newly created trendline and display the equation and the R-squared value.

Make sure that when you format the trendline Equation label, you set the numerical format to have a high degree of precision, so that all of the significant digits of the equation constants are displayed.

轻许诺言 2024-08-01 09:15:20

最简单的方法可能如下:

  1. 在此处下载 Excel 插件:XlXtrFun ™ Microsoft Excel 的额外功能

  2. 使用函数 intepolate()。
    =Interpolate($A$1:$A$3,$B$1:$B$3,D1,FALSE,FALSE)

A 列和 B 列应包含您的输入,G 列应包含您的所有日期值。 公式进入 E 列。

The easiest way to do it probably is as follows:

  1. Download Excel add-on here: XlXtrFun™ Extra Functions for Microsoft Excel

  2. Use function intepolate().
    =Interpolate($A$1:$A$3,$B$1:$B$3,D1,FALSE,FALSE)

Columns A and B should contain your input, and column G should contain all your date values. Formula goes into the column E.

橪书 2024-08-01 09:15:20

有两个函数,LINESTTREND,您可以尝试看看哪个可以给您带来更好的结果。 它们都采用一组已知的 X 和 Y 以及新的 X 值,并计算新的 Y 值。 不同之处在于,LINEST 执行简单的线性回归,而 TREND 在执行回归之前会首先尝试找到一条适合您的数据的曲线。

There are two functions, LINEST and TREND, that you can try to see which gives you the better results. They both take sets of known Xs and Ys along with a new X value, and calculate a new Y value. The difference is that LINEST does a simple linear regression, while TREND will first try to find a curve that fits your data before doing the regression.

孤星 2024-08-01 09:15:20

YGA 的上述答案不处理所需 X 值与参考范围的 X 值相同的范围结束情况。 使用 YGA 给出的示例,Excel 公式将返回 #DIV/0! 如果要求 9999 处的插值,则会出错。 这显然是 YGA 将 9999 和 -9999 的极值端点添加到输入数据范围,然后假设所有预测值都在这两个数字之间的部分原因。 如果不需要或不可能进行这种填充,还有另一种方法可以避免 #DIV/0! 错误是使用以下公式检查输入值是否精确匹配:

=IF(ISNA(MATCH(F3,inputs,0)),FORECAST(F3,OFFSET(inputs,MATCH(F3,inputs)-1,1,2,1),OFFSET(inputs,MATCH(F3,inputs)-1,0,2,1)),OFFSET(inputs,MATCH(F3,inputs)-1,1,1,1))

其中 F3 是需要插值结果的值。

注意:我刚刚将其添加为原始 YGA 帖子的评论,但我还没有足够的声誉点。

The answer above by YGA doesn't handle end of range cases where the desired X value is the same as the reference range's X value. Using the example given by YGA, the excel formula would return #DIV/0! error if an interpolated value at 9999 was asked for. This is obviously part of the reason why YGA added the extreme endpoints of 9999 and -9999 to the input data range, and then assumes that all forecasted values are between these two numbers. If such padding is undesired or not possible, another way to avoid a #DIV/0! error is to check for an exact input value match using the following formula:

=IF(ISNA(MATCH(F3,inputs,0)),FORECAST(F3,OFFSET(inputs,MATCH(F3,inputs)-1,1,2,1),OFFSET(inputs,MATCH(F3,inputs)-1,0,2,1)),OFFSET(inputs,MATCH(F3,inputs)-1,1,1,1))

where F3 is the value where interpolated results are wanted.

Note: I would have just added this as a comment to the original YGA post, but I don't have enough reputation points yet.

梦幻的心爱 2024-08-01 09:15:20

或者。

=INDEX(yVals,MATCH(J7,xVals,1))+(J7-MATCH(J7,xVals,1))*(INDEX(yVals,MATCH(J7,xVals,1)+1)-INDEX(yVals,MATCH(J7,xVals,1)))/(INDEX(xVals,MATCH(J7,xVals,1)+1)-MATCH(J7,xVals,1))

其中 j7 是 x 值。

xvals 是 x 值的范围
yvals 是 y 值的范围,

更容易将其放入代码中。

alternatively.

=INDEX(yVals,MATCH(J7,xVals,1))+(J7-MATCH(J7,xVals,1))*(INDEX(yVals,MATCH(J7,xVals,1)+1)-INDEX(yVals,MATCH(J7,xVals,1)))/(INDEX(xVals,MATCH(J7,xVals,1)+1)-MATCH(J7,xVals,1))

where j7 is the x value.

xvals is range of x values
yvals is range of y values

easier to put this into code.

不念旧人 2024-08-01 09:15:20

您可以使用 Excel 的“趋势线”功能找出最适合您的数据的公式。 使用该公式,您可以计算任何 xy

  1. 为其创建线性散点图 (XY)(Insert => Scatter);
  2. 创建多项式或移动平均趋势线,选中“在
    图表”(右键单击系列 => 添加趋势线);
  3. 将方程复制到单元格中,并将 x 替换为您想要的 x 值

在下面的屏幕截图中,A12:A16 包含 x< /code> 的,B12:B16 保存 y 的,C12 包含计算任何 xy 的公式

。 "https://i.sstatic.net/ZUjPs.jpg" rel="nofollow noreferrer">Excel 插值

我首先在此处发布了答案,但后来发现了这个问题

You can find out which formula fits best your data, using Excel's "trend line" feature. Using that formula, you can calculate y for any x

  1. Create linear scatter (XY) for it (Insert => Scatter);
  2. Create Polynominal or Moving Average trend line, check "Display Equation on
    chart" (right-click on series => Add Trend Line);
  3. Copy the equation into cell and replace x's with your desired x value

On screenshot below A12:A16 holds x's, B12:B16 holds y's, and C12 contains formula that calculates y for any x.

Excel Interpolation

I first posted an answer here, but later found this question

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