平均數、變異數與常態分配

Python 投資組合風險管理入門

Dakota Wixom

Quantitative Analyst | QuantCourse.com

分配的動差

機率分配的動差如下:

  • 1) 平均數($ \mu $)
  • 2) 變異數($ \sigma ^ 2 $)
  • 3) 偏態(Skewness)
  • 4) 峰度(Kurtosis)
Python 投資組合風險管理入門

分配類型很多。有些是常態,有些則非。具有 Gaussian distribution 的隨機變數稱為「常態分配」。

常態分配的性質:

  • 平均數 = $ \mu $
  • 變異數 = $ \sigma ^ 2 $
  • 偏態 = 0
  • 峰度 = 3

Python 投資組合風險管理入門

標準常態分配

標準常態(Standard Normal) 是常態分配的一個特例,當:

  • $ \sigma $ = 1
  • $ \mu $ = 0
Python 投資組合風險管理入門

與常態分配比較

  • 常態分配的偏態接近 0、峰度接近 3。
  • 金融報酬通常不是常態分配
  • 金融報酬可能具有高峰度
Python 投資組合風險管理入門

與常態分配比較

Python 投資組合風險管理入門

在 Python 中計算平均報酬

要計算每日平均報酬,使用 np.mean()

import numpy as np
np.mean(StockPrices["Returns"])
0.0003

要計算年化平均報酬(假設一年有 252 個交易日):

import numpy as np
((1+np.mean(StockPrices["Returns"]))**252)-1
0.0785
Python 投資組合風險管理入門

標準差與變異數

標準差(波動度)

  • 變異數 = $ \sigma ^ 2 $
  • 常以 $ \sigma $ 表示,或稱為「波動度」
  • 較高的 $ \sigma $ 代表投資風險較高
  • 衡量報酬的離散程度

Python 投資組合風險管理入門

在 Python 中計算標準差與變異數

假設 StockData 物件已載入股票報酬資料。要計算期間報酬的標準差:

import numpy as np
np.std(StockPrices["Returns"])
0.0256

要計算變異數,只要將標準差平方:

np.std(StockPrices["Returns"])**2
0.000655
Python 投資組合風險管理入門

波動度縮放

  • 波動度會隨時間平方根縮放
  • 一般可假設一年 252 個交易日、每月 21 個交易日

Python 投資組合風險管理入門

在 Python 中縮放波動度

假設 StockData 物件已載入股票報酬資料。要計算報酬的年化波動度:

import numpy as np
np.std(StockPrices["Returns"]) * np.sqrt(252)
0.3071
Python 投資組合風險管理入門

一起來練習吧!

Python 投資組合風險管理入門

Preparing Video For Download...