Best fit curve for trend line
Posted
by Dave Jarvis
on Stack Overflow
See other posts from Stack Overflow
or by Dave Jarvis
Published on 2010-03-23T22:57:04Z
Indexed on
2010/03/23
23:43 UTC
Read the original article
Hit count: 460
Problem Constraints
- Size of the data set, but not the data itself, is known.
- Data set grows by one data point at a time.
- Trend line is graphed one data point at a time (using a spline/Bezier curve).
Graphs
The collage below shows data sets with reasonably accurate trend lines:
The graphs are:
- Upper-left. By hour, with ~24 data points.
- Upper-right. By day for one year, with ~365 data points.
- Lower-left. By week for one year, with ~52 data points.
- Lower-right. By month for one year, with ~12 data points.
User Inputs
The user can select:
- the type of time series (hourly, daily, monthly, quarterly, annual); and
- the start and end dates for the time series.
For example, the user could select a daily report for 30 days in June.
Trend Weight
To calculate the window size (i.e., the number of data points to average when calculating the trend line), the following expression is used:
data points / trend weight
Where data points
is derived from user inputs and trend weight
is 6.4. Even though a trend weight of 6.4 produces good fits, it is rather arbitrary, and might not be appropriate for different user inputs.
Question
How should trend weight
be calculated given the constraints of this problem?
© Stack Overflow or respective owner