[Math] Exponential Moving Average (EMA)

2024. 11. 22. 12:04·.../Math
728x90
728x90

Definition

moving average (=rolling average or running average)

  • 데이터 포인트를 분석하기 위한
  • 전체 데이터 집합에서 연속적인 부분 집합들의 평균을 계산하는
  • 통계적 방법이다.

일반적으로 MA는 다음과 같이 모든 데이터 동일한 가중치를 부여한다:

$$\text{MA}_n = \frac{1}{n} \sum_{i=0}^{n-1} x_{t-i}$$

 

MA 중에서도 EMA는

  • 최근의 데이터에 더 큰 가중치를 주고
  • 오래된 데이터일수록 지수적으로(exponentially) 감소하는 가중치를 적용하여
  • 계산하는 이동 평균 임.

$$\begin{aligned}\text{EMA}_n &= \sum_{i=0}^{\infty} (1-\beta) \beta^i x_{t-i} \\ &= (1-\beta) x_t + \beta \text{EMA}_{t-1}\end{aligned}$$

주의: EMA는 Auto-regressive model임.

 

더보기

2024.11.23 - [.../Signals and Systems] - [SS] Discrete System Representation: DE, MA, AR, ARMA, ARIMA, SARIMA

 

[SS] Discrete System Representation: DE, MA, AR, ARMA, ARIMA, SARIMA

신호처리 관점에서의 시스템 표현: 차분 방정식과 MA, AR, ARMA, ARIMA, SARIMA 모델신호처리에서 이산 신호 시스템은 FIR(Finite Impulse Response) 시스템과 IIR(Infinite Impulse Response) 시스템으로 분류할 수 있음

dsaint31.tistory.com



The EMA $y$ for a series $x$ may be calculated recursively:

$$
\begin{aligned}y_{t}&={\begin{cases}x_{1},&t=1 \\ (1-\beta) \cdot x_{t}+ \beta \cdot y_{t-1},&t>1\end{cases}} \\ &={\begin{cases}x_{1},&t=1 \\ \alpha \cdot x_{t}+(1-\alpha)\cdot y_{t-1},&t>1\end{cases}}\end{aligned}
$$

Where:

  • $x_t$ is the value at a time $t$.(시간 간격) <= 즉, 가장 최근 데이터.
  • $y_t$ is the value of the EMA at any time $t$. <= $t$ 에서의 EMA
  • The coefficient $\beta$ represents decay / momentum / memory coefficient between 0 and 1.
    • $\beta$ is called a exponetial decay (or momentum) constant between 0 and 1. (DL등에선 0.9 수준)
    • $\alpha$ : update rate ($1-\beta$)
    • A higher $\alpha$ discounts older observations faster. => 즉, $\alpha$가 낮을수록 ($\beta$가 높을수록), EMA곡선이 smooth해짐.
    • 일반적 time series analysis 로 $\alpha=\frac{2}{1+N}$ (or $\beta = 1-\frac{2}{1+N}=\frac{N-1}{1+N}$)을 취하는데
      (전자를 주로 취함),
    • 여기서 $N$은 Simple Moving Average 등을 계산할 때의 span, 즉, EMA를 계산할 때 사용하는 subset의 크기(effective window)로 간주.
    • As a rule of thumb, EMA는 최근 $\frac{1}{\alpha}=\frac{1}{1-\beta}$개의 sample에 대한 평균 (=averaging over window of $\frac{1}{\alpha}$ samples)으로 보기도 함:effective window

이름의 유래

Exponentially Weighted Moving Average는
MA에서 특정 데이터의 영향(weight)이 Exponentially decay가 되는 데에서 이름이 유래됨. :

  • EMA는 이 전의 값(위 식의 $y_{t-1}$ )에 비례($\beta$)하여
  • 현재의 EMA에 영향을 주기 때문에 Exponential decay가 됨.

이름과 다르게
EMA는
MA 모델이 아닌
AR모델에 해당함.


Mathematical Proof of EMA's Exponential Decay:
A Differential Equation Approach

$$
\begin{aligned}Y_{t+1}-Y_t &= -\beta Y_t \\ Y' &=-\beta Y\\ \frac{dY}{dt}&=-\beta Y\\ \int \frac{1}{Y} dY&=\int -\beta dt\\ \ln Y +C_1&= -\beta t+ C_2 \\ \ln Y &= -\beta t + C_3 \\ Y &=e^{-\beta t + C_3}\\ Y&=e^{C_3}e^{-\beta t}\\Y&=Ae^{-\beta t}\end{aligned}
$$

위 식에서

  • $\beta$가 0 보다 작을 경우(앞에 -기호때문에), exponential growth
  • $\beta$가 0 일 경우, constant
  • $\beta$가 0 보다 클 경우, exponential decay임.

참고로 $C_1, C_2, C_3$는 적분 상수(integration constants)이며, $A=e^{C_3}$는 초기 조건에 의해 결정되는 상수임.

  • $C_3=C_2-C_1$
  • $A=e^{C_3}$

같이보면 좋은 자료들

2024.11.23 - [.../Signals and Systems] - [SS] Discrete System Representation: DE, MA, AR, ARMA, ARIMA, SARIMA

 

[SS] Discrete System Representation: DE, MA, AR, ARMA, ARIMA, SARIMA

신호처리 관점에서의 시스템 표현: 차분 방정식과 MA, AR, ARMA, ARIMA, SARIMA 모델신호처리에서 이산 신호 시스템은 FIR(Finite Impulse Response) 시스템과 IIR(Infinite Impulse Response) 시스템으로 분류할 수 있음

dsaint31.tistory.com

2024.11.22 - [.../Signals and Systems] - [SS] Structural Characteristics of Discrete Signals (or Time-series Data) : 작성중

 

[SS] Structural Characteristics of Discrete Signals (or Time-series Data) : 작성중

Discrete Signal과 Time-series DataDiscrete signal은 이산 시간(discrete time)에서 측정된 값을 가지는 Signal이는 일반적으로 time series data의 한 형태로 볼 수 있음.시간의 discrete point에서 정의된 signal은 시간적

dsaint31.tistory.com


 

728x90

'... > Math' 카테고리의 다른 글

[Math] Extremum Point, Inflection Point, Saddle Point, Convex and Concave.  (2) 2025.01.05
[Math] Binomial Theorem (이항정리)  (0) 2025.01.04
[Math] Basis  (0) 2024.10.28
[Math] Inner Product (or Hermitian Inner Product, 내적)  (6) 2024.10.28
[Statistics] Tail, Head, and Distribution (w/ Moment)  (0) 2024.09.26
'.../Math' 카테고리의 다른 글
  • [Math] Extremum Point, Inflection Point, Saddle Point, Convex and Concave.
  • [Math] Binomial Theorem (이항정리)
  • [Math] Basis
  • [Math] Inner Product (or Hermitian Inner Product, 내적)
dsaint31x
dsaint31x
    반응형
    250x250
  • dsaint31x
    Dsaint31's blog
    dsaint31x
  • 전체
    오늘
    어제
    • 분류 전체보기 (787)
      • Private Life (15)
      • Programming (55)
        • DIP (116)
        • ML (35)
      • Computer (120)
        • CE (54)
        • ETC (33)
        • CUDA (3)
        • Blog, Markdown, Latex (4)
        • Linux (9)
      • ... (368)
        • Signals and Systems (115)
        • Math (176)
        • Linear Algebra (33)
        • Physics (43)
        • 인성세미나 (1)
      • 정리필요. (61)
        • 의료기기의 이해 (6)
        • PET, MRI and so on. (7)
        • PET Study 2009 (1)
        • 방사선 장해방호 (5)
        • 방사선 생물학 (3)
        • 방사선 계측 (9)
        • 기타 방사능관련 (3)
        • 고시 (9)
        • 정리 (18)
      • RI (0)
      • 원자력,방사능 관련법 (2)
  • 블로그 메뉴

    • Math
    • Programming
    • SS
    • DIP
  • 링크

    • Convex Optimization For All
  • 공지사항

    • Test
    • PET Study 2009
    • 기타 방사능관련.
  • 인기 글

  • 태그

    SIGNAL
    random
    math
    Vector
    opencv
    Programming
    Probability
    linear algebra
    function
    인허가제도
    numpy
    cv2
    Optimization
    signals_and_systems
    Term
    signal_and_system
    Python
    fourier transform
    SS
    ML
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
dsaint31x
[Math] Exponential Moving Average (EMA)
상단으로

티스토리툴바