当x轴使用日期时计算趋势线 [英] Calculate a trendline when the x-axis uses dates

查看:317
本文介绍了当x轴使用日期时计算趋势线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关在散点图上计算趋势线的帖子(我如何计算图形的趋势线?)很有帮助,但是我很好奇如何在x轴是DateTime字段而不是整数的图形上找到趋势线.例如,考虑将图表上的订阅者数量随时间变化的图表:

The post on calculating trend lines on a scatter plot (How do I calculate a trendline for a graph?) is quite helpful, but I'm curious how one could go about finding a trend line on a graph where the x-axis is a DateTime field, rather than an integer. For example, consider the case of charting the number of subscribers to a mailing list over time:

1月1日:100个订阅者
1月2日:105位订阅者
1月5日:120位订阅者
1月10日:117位订阅者
等等...

Jan 1: 100 subscribers
Jan 2: 105 subscribers
Jan 5: 120 subscribers
Jan 10: 117 subscribers
etc...

我遇到的问题是弄清楚它的运行"(增量x)部分...由于间隔不会均匀分布,我们不能仅仅假设经过了一个单位的时间每次测量之间.我有一种预感,我必须计算出某种规模,但我被困在那儿.

The problem I'm running into is figuring out the 'run' (delta x) portion of this... since the intervals are not going to be evenly spaced, we can't just assume a single unit of time passing between each measurement. I've got a hunch that I'll have to work out some sort of scale, but I'm stuck there.

任何人都可以解释当x轴是DateTime字段时如何计算趋势线吗? (如果您发布代码示例,则最好使用C#,VB.NET或Java!)

Can anyone explain how to calculate a trendline when the x-axis is a DateTime field? (If you post a code sample, C#, VB.NET, or Java would be most appreciated!)

推荐答案

您将必须进行某种线性插值.您需要将日期和时间转换为线性比例.好消息是您可以选择这个比例.因此,计算自情节开始以来经过了几分钟,几秒钟或几小时....然后,您可以将其用作运行"部分.

You'll have to do a sort of linear interpolation. You need to convert the dates and times to a linear scale. The good news is that you get to pick this scale. So calculate how many minutes, or seconds, or hours... have passed since the start of your plot. You can then use this as the "run" portion.

在您的示例中,我们可以休息几天:

In your example, we can go off of days:

1月1日:0天,有100位订阅者 1月2日:1天,105位订阅者 1月5日:4天,有120位订阅者 1月10日:9天,有117位订阅者

Jan 1: 0 days, 100 subscribers Jan 2: 1 day, 105 subscribers Jan 5: 4 days, 120 subscribers jan 10: 9 days, 117 subscribers

这篇关于当x轴使用日期时计算趋势线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆