1. <small id='afeN3'></small><noframes id='afeN3'>

      <tfoot id='afeN3'></tfoot>

        <legend id='afeN3'><style id='afeN3'><dir id='afeN3'><q id='afeN3'></q></dir></style></legend>

          <bdo id='afeN3'></bdo><ul id='afeN3'></ul>

      1. <i id='afeN3'><tr id='afeN3'><dt id='afeN3'><q id='afeN3'><span id='afeN3'><b id='afeN3'><form id='afeN3'><ins id='afeN3'></ins><ul id='afeN3'></ul><sub id='afeN3'></sub></form><legend id='afeN3'></legend><bdo id='afeN3'><pre id='afeN3'><center id='afeN3'></center></pre></bdo></b><th id='afeN3'></th></span></q></dt></tr></i><div id='afeN3'><tfoot id='afeN3'></tfoot><dl id='afeN3'><fieldset id='afeN3'></fieldset></dl></div>

        TimeSeries 趋势数据的重采样、聚合和插值

        时间:2023-08-27

        <small id='x0796'></small><noframes id='x0796'>

          <bdo id='x0796'></bdo><ul id='x0796'></ul>

            • <i id='x0796'><tr id='x0796'><dt id='x0796'><q id='x0796'><span id='x0796'><b id='x0796'><form id='x0796'><ins id='x0796'></ins><ul id='x0796'></ul><sub id='x0796'></sub></form><legend id='x0796'></legend><bdo id='x0796'><pre id='x0796'><center id='x0796'></center></pre></bdo></b><th id='x0796'></th></span></q></dt></tr></i><div id='x0796'><tfoot id='x0796'></tfoot><dl id='x0796'><fieldset id='x0796'></fieldset></dl></div>

                    <tbody id='x0796'></tbody>

                1. <legend id='x0796'><style id='x0796'><dir id='x0796'><q id='x0796'></q></dir></style></legend><tfoot id='x0796'></tfoot>
                  本文介绍了TimeSeries 趋势数据的重采样、聚合和插值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  在分析能源需求和消耗数据时,我在重新采样和插值时间序列趋势数据时遇到问题.

                  In analysis of energy demand and consumption data, I'm having issue re-sampling and interpolating time series trended data.

                  数据集示例:

                  timestamp                value kWh
                  ------------------       ---------
                  12/19/2011 5:43:21 PM    79178
                  12/19/2011 5:58:21 PM    79179.88
                  12/19/2011 6:13:21 PM    79182.13
                  12/19/2011 6:28:21 PM    79183.88
                  12/19/2011 6:43:21 PM    79185.63
                  

                  根据这些观察结果,我想要一些聚合以基于一段时间汇总值,并将频率设置为一个时间单位.

                  Based upon these observations, I'd like some aggregation to roll-up values based upon a period of time, with that frequency set to a unit of time.

                  例如,每小时的间隔填补缺失数据的任何空白

                  As in, intervals on the hour filling any gaps of missing data

                  timestamp                value (approx)
                  ------------------       ---------
                  12/19/2011 5:00:00 PM    79173
                  12/19/2011 6:00:00 PM    79179
                  12/19/2011 7:00:00 PM    79186
                  

                  对于线性算法,似乎我会取时间差并将值与该因子相乘.

                  For a linear algorithm, it seems I would take the difference in time and multiply the value against that factor.

                  TimeSpan ts = current - previous;
                  
                  Double factor = ts.TotalMinutes / period;
                  

                  值和时间戳可以根据因子计算.

                  Value and timestamp could be calculated based upon the factor.

                  有了如此多的可用信息,我不确定为什么很难找到最优雅的方法.

                  With such quantity of available information, I'm unsure why it's difficult to find the most elegant approach to this.

                  也许首先,有没有可以推荐的开源分析库?

                  Perhaps first, are there open source analysis libraries that could be recommended?

                  对程序化方法有什么建议吗?理想情况下是 C#,还是可能使用 SQL?

                  Any recommendations for a programmatic approach? Ideally C#, or possibly with SQL?

                  或者,我可以指出任何类似的问题(有答案)?

                  Or, any similar questions (with answers) I could be pointed to?

                  推荐答案

                  通过使用内部用于表示 DateTimes 的时间刻度,您可以获得尽可能准确的值.由于这些时间刻度不会在午夜从零重新开始,因此您不会在日期边界处遇到问题.

                  By using the time-ticks that are used internally to represent DateTimes, you get the most accurate values that are possible. Since these time ticks do not restart at zero at midnight, you will not have problems at day boundaries.

                  // Sample times and full hour
                  DateTime lastSampleTimeBeforeFullHour = new DateTime(2011, 12, 19, 17, 58, 21);
                  DateTime firstSampleTimeAfterFullHour = new DateTime(2011, 12, 19, 18, 13, 21);
                  DateTime fullHour = new DateTime(2011, 12, 19, 18, 00, 00);
                  
                  // Times as ticks (most accurate time unit)
                  long t0 = lastSampleTimeBeforeFullHour.Ticks;
                  long t1 = firstSampleTimeAfterFullHour.Ticks;
                  long tf = fullHour.Ticks;
                  
                  // Energy samples
                  double e0 = 79179.88; // kWh before full hour
                  double e1 = 79182.13; // kWh after full hour
                  double ef; // interpolated energy at full hour
                  
                  ef = e0 + (tf - t0) * (e1 - e0) / (t1 - t0); // ==> 79180.1275 kWh
                  

                  公式说明
                  在几何学中,相似三角形是形状相同但大小不同的三角形.上面的公式是基于一个三角形中任意两条边的比率对于相似三角形的对应边相同的事实.

                  Explanation of the formula
                  In geometry, similar triangles are triangles that have the same shape but different sizes. The formula above is based on the fact that the ratios of any two sides in one triangle are the same for the corresponding sides of a similar triangle.

                  如果你有一个三角形 A B C 和一个相似的三角形 a b c,那么 A : B = a : b.两个比率相等称为比例.

                  If you have a triangle A B C and a similar triangle a b c, then A : B = a : b. The equality of two ratios is called a proportion.

                  我们可以将此比例规则应用于我们的问题:

                  We can apply this proportionality rule to our problem:

                  (e1 – e0) / (t1 – t0) = (ef – e0) / (tf – t0)
                  --- large triangle --   --- small triangle --
                  

                  这篇关于TimeSeries 趋势数据的重采样、聚合和插值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:重定向 cmd.exe 的输入和输出 下一篇:忽略字符串比较中的重音字母

                  相关文章

                  最新文章

                    • <bdo id='FrSaq'></bdo><ul id='FrSaq'></ul>
                  1. <i id='FrSaq'><tr id='FrSaq'><dt id='FrSaq'><q id='FrSaq'><span id='FrSaq'><b id='FrSaq'><form id='FrSaq'><ins id='FrSaq'></ins><ul id='FrSaq'></ul><sub id='FrSaq'></sub></form><legend id='FrSaq'></legend><bdo id='FrSaq'><pre id='FrSaq'><center id='FrSaq'></center></pre></bdo></b><th id='FrSaq'></th></span></q></dt></tr></i><div id='FrSaq'><tfoot id='FrSaq'></tfoot><dl id='FrSaq'><fieldset id='FrSaq'></fieldset></dl></div>
                    1. <legend id='FrSaq'><style id='FrSaq'><dir id='FrSaq'><q id='FrSaq'></q></dir></style></legend>
                    2. <small id='FrSaq'></small><noframes id='FrSaq'>

                      <tfoot id='FrSaq'></tfoot>