-
Notifications
You must be signed in to change notification settings - Fork 518
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
... for Data Science - Time Series/03.Time Series Analysis/07.Exponential Moving Average.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/************ Exponential Moving Average **********/ | ||
/* | ||
- A type of moving average | ||
- wights decrease exponentially | ||
- used to smooth trends when large variance in data | ||
Smoothing Parameter | ||
- typically 2 / (1+number of intervals) | ||
- example, for 7 days of smoothing parameter is 0.25 (2/1+7) | ||
- it is called lambda | ||
Lambda Formula | ||
- (current_period_value * lambda) + (previous_period_EWMA * (1-lambda)) | ||
- recursive | ||
- could be calculated using Common Table Expression, but not recommended for large data sets. | ||
- use User Defined function instead. | ||
*/ |