{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Gaussian Mixture and Leptokurtotic Assets\n",
    "\n",
    "Mixture of Gaussian distributions is an intuitive way to create \n",
    "distributions with skewness and kurtosis by adding \n",
    "two or more normal distributions.\n",
    "Such mixtures can synthesize *leptokurtosis* (\"fat tails\").\n",
    "\n",
    "Given the component variances of a GM(n) model it is easy,\n",
    "given the associated probabilities, to compute the moments\n",
    "of the resulting mixture. Our problem here is the *inverse*:\n",
    "from observable statistics, deduce the model parameters.\n",
    "This has been difficult due to solving tedious simultaneous\n",
    "equations for the so-called *method of moments problem*.\n",
    "However, with some simplications, the problem becomes\n",
    "tractable analytically and can provide insightful\n",
    "interpretations with concrete probabilities.\n",
    "\n",
    "We illustrate how a GM(2) model can synthesize Gaussian\n",
    "risk-equivalence for leptokurtotic financial assets.\n",
    "Both analytical and numerical solutions are provided.\n",
    "\n",
    "Appendix 1 confirms our analytical results by simulation.\n",
    "Also, we gain an experimental understanding of how kurtosis\n",
    "itself is distributed under small-sample conditions.\n",
    "\n",
    "Appendix 2 visualizes non-Gaussian distributions\n",
    "through quantile-quantile (Q-Q) probability plots.\n",
    "\n",
    "Appendix 3 points to Python package *scikit-learn*\n",
    "to fit multivariate Gaussian mixtures."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "VIEWING: *if you encounter this message,*\n",
    "[Math Processing Error], *it means\n",
    "GitHub is timing out on rendering LaTeX equations.\n",
    "Please view this notebook at*\n",
    "[Jupyter](http://nbviewer.jupyter.org/github/rsvp/fecon235/blob/master/nb/gauss-mix-kurtosis.ipynb)\n",
    "instead. Issue [#3](https://github.com/rsvp/fecon235/issues/3)\n",
    "has been raised in this regard.\n",
    "\n",
    "*Dependencies:*\n",
    "\n",
    "- Repository: https://github.com/rsvp/fecon235\n",
    "- Python: matplotlib, pandas, sympy\n",
    "\n",
    "*CHANGE LOG*\n",
    "\n",
    "    2017-06-02  Visual demo of plotqq() for non-Gaussian distributions.\n",
    "                   Refactor gm2_* code to module ys_gauss_mix.\n",
    "    2017-05-08  Edit sympy code. Simulation confirms theory.\n",
    "    2017-05-05  Solve GM(2) for 2nd and 4th moments.\n",
    "    2017-05-04  Minor edits.\n",
    "    2017-05-03  First rough draft."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from fecon235.fecon235 import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " ::  Python 2.7.13\n",
      " ::  IPython 5.1.0\n",
      " ::  jupyter_core 4.2.1\n",
      " ::  notebook 4.1.0\n",
      " ::  matplotlib 1.5.1\n",
      " ::  numpy 1.11.0\n",
      " ::  scipy 0.17.0\n",
      " ::  sympy 1.0\n",
      " ::  pandas 0.19.2\n",
      " ::  pandas_datareader 0.2.1\n",
      " ::  Repository: fecon235 v5.17.0221 develop\n",
      " ::  Timestamp: 2017-06-03T12:24:26Z\n",
      " ::  $pwd: /media/yaya/virt15h/virt/dbx/Dropbox/ipy/fecon235/nb\n"
     ]
    }
   ],
   "source": [
    "#  PREAMBLE-p6.15.1223d :: Settings and system details\n",
    "from __future__ import absolute_import, print_function, division\n",
    "system.specs()\n",
    "pwd = system.getpwd()   # present working directory as variable.\n",
    "print(\" ::  $pwd:\", pwd)\n",
    "#  If a module is modified, automatically reload it:\n",
    "%load_ext autoreload\n",
    "%autoreload 2\n",
    "#       Use 0 to disable this feature.\n",
    "\n",
    "#  Notebook DISPLAY options:\n",
    "#      Represent pandas DataFrames as text; not HTML representation:\n",
    "import pandas as pd\n",
    "pd.set_option( 'display.notebook_repr_html', False )\n",
    "from IPython.display import HTML # useful for snippets\n",
    "#  e.g. HTML('<iframe src=http://en.mobile.wikipedia.org/?useformat=mobile width=700 height=350></iframe>')\n",
    "from IPython.display import Image \n",
    "#  e.g. Image(filename='holt-winters-equations.png', embed=True) # url= also works\n",
    "from IPython.display import YouTubeVideo\n",
    "#  e.g. YouTubeVideo('1j_HxD4iLn8', start='43', width=600, height=400)\n",
    "from IPython.core import page\n",
    "get_ipython().set_hook('show_in_pager', page.as_hook(page.display_page), 0)\n",
    "#  Or equivalently in config file: \"InteractiveShell.display_page = True\", \n",
    "#  which will display results in secondary notebook pager frame in a cell.\n",
    "\n",
    "#  Generate PLOTS inside notebook, \"inline\" generates static png:\n",
    "%matplotlib inline   \n",
    "#          \"notebook\" argument allows interactive zoom and resize."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Gaussian mixture in general and its four moments\n",
    "\n",
    "We build upon the cumulative distribution function (cdf) $\\Phi$ of the standard Gaussian $N(0, 1)$.\n",
    "\n",
    "For $0\\leq p_i \\leq 1$ such that $\\sum_{i=1}^n{p_i} = 1$, \n",
    "we define **Gaussian mixture GM(n)** by the following cdf \n",
    "and the associated probability density function (pdf):\n",
    "\n",
    "$$\\begin{aligned}\n",
    "F_n(x) &= \\sum_{i=1}^{n}{p_i}\\Phi (\\frac{x-\\mu_i}{\\sigma_i}) \\\\\n",
    "f_n(x) &= \\sum_{i=1}^{n}{p_i}\\phi (x;\\mu_i,\\sigma_i^2) \\\\\n",
    "\\phi (x;\\mu_i,\\sigma_i^2) &= \\frac{1}{\\sqrt{2\\pi}\\sigma_i}e^{-{(x-\\mu_i)^2}/{(2\\sigma_i^2)}}  \n",
    "\\end{aligned}$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The *intuitive idea* boils down to having n jars, each containing real numbers\n",
    "which are normally distributed, specified only by their mean and variance. \n",
    "We then randomly pick $x$ from the i-th jar with probability $p_i$.\n",
    "This is essentially how we will later simulate GM(n)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Proposition 1:** The centralized moments of a Gaussian mixture GM(n) are:\n",
    "\n",
    "$$\\begin{aligned}\n",
    "\\mu &= \\sum_{i=1}^{n}{p_i}\\mu_i \\\\\n",
    "\\sigma^2 &= \\sum_{i=1}^{n}{p_i}(\\sigma_i^2+\\mu_i^2)-\\mu^2 \\\\\n",
    "skewness =: s &= \\frac{1}{\\sigma^3}\\sum_{i=1}^{n}{p_i}(\\mu_i-\\mu)[3\\sigma_i^2+(\\mu_i-\\mu)^2] \\\\\n",
    "kurtosis =: \\kappa &= \\frac{1}{\\sigma^4}\\sum_{i=1}^{n}{p_i}[3\\sigma_i^4+6(\\mu_i-\\mu)^2\\sigma_i^2+(\\mu_i-\\mu)^4]\n",
    "\\end{aligned}$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The history behind Proposition 1 goes back to Pearson (1894).\n",
    "The algebraic expressions used in solving the ***method of moments***\n",
    "in general are very tedious, see Cohen (1967) per Wang (2015, section 4.1).\n",
    "\n",
    "For the standard Gaussian distribution, $s=0$ and $\\kappa=3$.\n",
    "The importance of Proposition 1 is that mixture GM(n) can be a\n",
    "distribution with values for skewness and kurtosis which are non-standard.\n",
    "\n",
    "Returns on financial assets are said to be \"non-Gaussian.\"\n",
    "They are known to be \"fat-tailed\", or more technically,\n",
    "***leptokurtotic***: $\\kappa > 3$.\n",
    "This is where our mixture model can be helpful for risk management."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Moments of the zero-mean GM(2)\n",
    "\n",
    "We focus our attention to a mixture built with two Gaussians,\n",
    "and examine its *even* moments, $\\sigma^2$ and $\\kappa$\n",
    "by setting the component means $\\mu_i$ to zero.\n",
    "We can later account for a Gaussian mixture GM(2) with non-zero mean \n",
    "since the first *odd* moment of a distribution is merely an additive shift,\n",
    "without any deformation to shape."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Corollary 1.1:** For $p+q=1$ and $\\mu_1=\\mu_2=0$, \n",
    "the moments of this Gaussian mixture, which we shall call **zero-mean GM(2)**,\n",
    "are given by:\n",
    "\n",
    "$$\\begin{aligned}\n",
    "\\mu &= 0 \\\\ \n",
    "\\sigma^2 &= p\\sigma_1^2 + q\\sigma_2^2 \\\\ \n",
    "skewness =: s &= 0 \\\\\n",
    "kurtosis =: \\kappa &= \\frac{3}{\\sigma^4}[p\\sigma_1^4 + q\\sigma_2^4]\n",
    "\\end{aligned}$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Corollary 1.2:** Combining the equations for even moments,\n",
    "the following is a necessary condition for the **zero-mean GM(2)**: \n",
    "\n",
    "$$\\rm K := \\frac{\\kappa}{3} = \\frac{p\\sigma_1^4 + q\\sigma_2^4}{(p\\sigma_1^2 + q\\sigma_2^2)^2}$$\n",
    "\n",
    "Note: Our defined $\\rm K$ should not be confused with\n",
    "Fischer \"*excess kurtosis*\" := $\\kappa-3$\n",
    "(which is sometimes erroneously reported as the kurtosis statistic).\n",
    "Our $\\kappa$ is also known as the *Pearson* kurtosis."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Structured zero-mean GM(2)\n",
    "\n",
    "Given data set {$x$}, we can compute its variance and kurtosis.\n",
    "Thus, $\\sigma$ and $\\rm K$ are observable.\n",
    "Corollary 1.2 says that GM(2) parameters can indeed synthesize $\\rm K$,\n",
    "but its messiness suggests that we impose further structure for clarity.\n",
    "\n",
    "A sensible requirement is a strict ordering,\n",
    "$\\sigma_1 < \\sigma < \\sigma_2$\n",
    "in consideration of the weighted equation for $\\sigma^2$.\n",
    "We can impose this ordering by constrained constants $a$ and $b$."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Lemma 2.1:** Let $\\sigma_1 = a\\sigma$ and $b\\sigma = \\sigma_2$\n",
    "such that $0<a<1<b$, then for zero-mean GM(2)\n",
    "the following probability satisfies the condition for *kurtosis*:\n",
    "\n",
    "$$ p = \\frac{\\rm K - b^4}{a^4 - b^4}$$\n",
    "\n",
    "*PROOF*. Substitute the two equalities for $\\sigma$ into the kurtosis equation\n",
    "of Corollary 1.1. Also note that by construction: $q=1-p$.    $\\square$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Lemma 2.2:** Let $\\sigma_1 = a\\sigma$ and $b\\sigma = \\sigma_2$\n",
    "such that $0<a<1<b$, then for zero-mean GM(2)\n",
    "the following probability satisfies the condition for *variance*:\n",
    "\n",
    "$$ p = \\frac{1 - b^2}{a^2 - b^2}$$\n",
    "\n",
    "*PROOF*. Substitute the two equalities for $\\sigma$ into the $\\sigma^2$ equation\n",
    "of Corollary 1.1. Also note that by construction: $q=1-p$.    $\\square$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Proposition 2:** Let $\\sigma_1 = a\\sigma$ and $b\\sigma = \\sigma_2$\n",
    "such that $0<a<1<b$, then for zero-mean GM(2)\n",
    "the following satisfies conditions for both *kurtosis* and *variance*:\n",
    "\n",
    "$$\\frac{\\rm K - b^4}{a^4 - b^4} = \\frac{1 - b^2}{a^2 - b^2}$$\n",
    "\n",
    "*PROOF*. Immediate from Lemma 2.1 and 2.2.    $\\square$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Analytic strategy and conclusion\n",
    "\n",
    "Proposition 2 shows how constants $a$ and $b$ are jointly constrained\n",
    "by the moments of the Gaussian mixture.\n",
    "\n",
    "Our **strategy** will be to choose $b>1$, then use the kurtosis $\\kappa$\n",
    "to compute $a$. Probability $p$ can then be computed using\n",
    "Lemma 2.2, for which $q=1-p$ follows.\n",
    "Since $\\sigma_1 = a\\sigma$ and $b\\sigma = \\sigma_2$\n",
    "the components of our zero-mean GM(2) are fully resolved,\n",
    "given specific $\\sigma$.\n",
    "This strategy will satisfy the necessary condition derived in Corollary 1.2.\n",
    "\n",
    "From two observable statistics $\\sigma$ and $\\kappa$,\n",
    "we have *deduced*, not fitted, the parameters of a zero-mean GM(2).\n",
    "An observable mean $\\mu$ which is non-zero can be added to\n",
    "our model to obtain a zero-skew GM(2).\n",
    "\n",
    "Fitting a general Gaussian mixture is computational very intensive,\n",
    "and for returns on financial assets, the results are often\n",
    "not robust (see Appendix 3). Our analytical method of moments\n",
    "allows us to constrain parameters in a way which has an optimal\n",
    "interpretation in Hilbert space, which for finance\n",
    "boils down to the Markowitz mean-variance framework.\n",
    "(An alternative model of leptokurtosis, the jump-diffusion process,\n",
    "does not have such an ideal mathematical interpretation.)\n",
    "\n",
    "---"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Numerically solving Proposition 2\n",
    "\n",
    "Given $b$ we could analytically solve for $a$ rewriting the solution for quadratic equations.\n",
    "Instead we shall demostrate the use of Python's sympy package (imported as *sym*) for symbolic mathematics."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\u001b[0;31mSignature:\u001b[0m \u001b[0mgm2_strategy\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkurtosis\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
       "\u001b[0;31mSource:\u001b[0m   \n",
       "\u001b[0;32mdef\u001b[0m \u001b[0mgm2_strategy\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkurtosis\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0;34m'''Use sympy to solve for \"a\" in Proposition 2 numerically.\u001b[0m\n",
       "\u001b[0;34m    >>> round( gm2_strategy(7, 2), 4 )\u001b[0m\n",
       "\u001b[0;34m    0.7454\u001b[0m\n",
       "\u001b[0;34m    '''\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0;31m#  sym.init_printing(use_unicode=True)\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0;31m#  #        ^required if symbolic output is desired.\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0ma\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msym\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msymbols\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'a'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0mK\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mkurtosis\u001b[0m \u001b[0;34m/\u001b[0m \u001b[0;36m3.0\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0;31m#  Use equation from Prop. 2\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0mLHS\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mK\u001b[0m \u001b[0;34m-\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0;36m4\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m/\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0;36m4\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m-\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0;36m4\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0mRHS\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m \u001b[0;34m-\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m/\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m-\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0ma_solved\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msym\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msolveset\u001b[0m\u001b[0;34m(\u001b[0m \u001b[0msym\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mEq\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mLHS\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mRHS\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdomain\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0msym\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mS\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mReals\u001b[0m \u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0;31m#  ... expect negative and positve real solutions\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0;31m#      provided in sympy's FiniteSet format.\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0;32mif\u001b[0m \u001b[0ma_solved\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0msym\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mS\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mEmptySet\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m        \u001b[0;31m#               ^when no feasible solution was found in domain.\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m        \u001b[0;31m#                Do not accept imaginary solutions :-)\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m        \u001b[0msystem\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdie\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Argument b could not treat kurtosis; INCREASE b.\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m        \u001b[0;31m#     ^dies when kurtosis > 12 and b=2, for example.\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m        \u001b[0;31m#           SPX returns since 1957 have kurtosis around 31.6\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m        \u001b[0;31m#           which is very high, requiring b>3.4 for feasiblity.\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m        \u001b[0;31m#  But a>0 by construction, so extract the positive real number:\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m        \u001b[0ma_positive\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmax\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlist\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma_solved\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0;32mreturn\u001b[0m \u001b[0ma_positive\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
       "\u001b[0;31mFile:\u001b[0m      ~/Dropbox/ipy/fecon235/lib/ys_gauss_mix.py\n",
       "\u001b[0;31mType:\u001b[0m      function\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "gm2_strategy??"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In writing the function `gm2_strategy`, we find that\n",
    "even a numerical solution (as opposed to a symbolic one)\n",
    "constrained to the real domain (as opposed to the complex) is messy.\n",
    "Surprisingly, $b$ is not entirely a *free* parameter\n",
    "since its particular value may be inadmissible when kurtosis is large.\n",
    "The function will work when $b$ is adjusted slightly higher\n",
    "when kurtosis is large enough to generate a fatal error."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.745355992499930"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#  Example of deducing constant \"a\"\n",
    "#  using default value for \"b\":\n",
    "gm2_strategy(kurtosis=7, b=2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      " !!  FATAL 1: __main__.py Argument b could not treat kurtosis; INCREASE b.\n"
     ]
    },
    {
     "ename": "SystemExit",
     "evalue": "1",
     "output_type": "error",
     "traceback": [
      "An exception has occurred, use %tb to see the full traceback.\n",
      "\u001b[0;31mSystemExit\u001b[0m\u001b[0;31m:\u001b[0m 1\n"
     ]
    }
   ],
   "source": [
    "#  Example of deducing constant \"a\", INTENTIONALLY fatal:\n",
    "\n",
    "#  gm2_strategy(kurtosis=15, b=2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.487950036474267"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#  Example of deducing constant \"a\"\n",
    "#  and re-adjustment of b given high kurtosis:\n",
    "gm2_strategy(kurtosis=15, b=2.5)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Numerical solution for GM(2)\n",
    "\n",
    "So for suitably chosen b, we can implement our strategy\n",
    "to completely specify our GM(2) model:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\u001b[0;31mSignature:\u001b[0m \u001b[0mgm2_main\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkurtosis\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msigma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
       "\u001b[0;31mSource:\u001b[0m   \n",
       "\u001b[0;32mdef\u001b[0m \u001b[0mgm2_main\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkurtosis\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msigma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0;34m'''Compute specs for GM(2) given observable statistics and b.'''\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0ma\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mgm2_strategy\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mkurtosis\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0;31m#  Probability p as given in Lemma 2.2:\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0mp\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m \u001b[0;34m-\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m/\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m-\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0;31m#   The returned parameters can then be used in simulations, \u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0;31m#   e.g. simug_mix() in lib/yi_simulation.py module,\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0;31m#   or for synthetic assets in risk management:\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0;32mreturn\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mp\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0ma\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0msigma\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0mp\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0msigma\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
       "\u001b[0;31mFile:\u001b[0m      ~/Dropbox/ipy/fecon235/lib/ys_gauss_mix.py\n",
       "\u001b[0;31mType:\u001b[0m      function\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "gm2_main??"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Constants a, b: [0.745355992499930, 2]\n",
      "GM(2), p:  0.870967741935484\n",
      "GM(2), sigma1: 0.0968962790249909\n",
      "GM(2), q:  0.129032258064516\n",
      "GM(2), sigma2: 0.26\n"
     ]
    }
   ],
   "source": [
    "#  Demo of zero-mean GM(2) parameters using gm2_main():\n",
    "gm2_print(kurtosis=7, sigma=0.13, b=2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Numerical application in finance\n",
    "\n",
    "Suppose we are examining the returns of a financial asset XYZ\n",
    "and find evidence of a leptokurtotic distribution where $\\kappa=7$.\n",
    "Clearly this is non-Gaussian (though kurtosis estimates\n",
    "are not known to be stable due to their fourth power).\n",
    "The annualized volatility was observed to be 13%, \n",
    "so $\\sigma=0.13$ and we wish to use the GM(2) model\n",
    "to manage risk.\n",
    "\n",
    "We establish two synthetic assets on our books to represent XYZ\n",
    "by our choice of constrained constant $b$:\n",
    "\n",
    "- XYZ1 with volatility $a\\sigma$ where $a=0.7454$ is deduced,\n",
    "- XYZ2 with volatility $b\\sigma$ where $b=2.0000$\n",
    "\n",
    "The idea here is that XYZ1 models XYZ behaviour\n",
    "during normal trading (with probability $p=0.8710$),\n",
    "while XYZ2 models XYZ in an extremely volatile environment\n",
    "(with probability $q=0.1290$).\n",
    "\n",
    "Note that if kurtosis should increase, then upon recomputation, \n",
    "$q$ will increase because more \"fat-tail\" risk has emerged.\n",
    "\n",
    "We can still use our structured zero-mean GM(2) with\n",
    "*non-zero* mean returns because the mean is an *odd* moment\n",
    "merely providing an additive shift -- without changing\n",
    "the *shape* of the distribution. The pressing issue was \n",
    "actually getting suitable probability weights $p$ and $q$.\n",
    "\n",
    "If \\$100,000 of XYZ was on our books at 13% volatility, we use the\n",
    "probability weights to replace it with: \n",
    "- \\$87,097 of XYZ1 at 9.69% volatility, and\n",
    "- \\$12,903 of XYZ2 at 26% volatility.\n",
    "\n",
    "Important to emphasize that synthetic assets XYZ1 and XYZ2\n",
    "are Gaussian assets, so we are free to use the \n",
    "optimal linear mean-variance framework,\n",
    "yet the leptokurtotic risks are approximately covered.\n",
    "GM models are excellent extensions for\n",
    "VaR (Value at Risk) evaluations."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "\n",
    "***Historical note:*** The specifics of the XYZ asset were actually *stylized*\n",
    "after SPX (S&P 500 index). The volatility from 2012 to 2017 was approximately\n",
    "12.5%, and during the Great Recession from 2007 to 2012 the volatility was 26.5%.\n",
    "So $b=2$ is not unreasonable since the volatility was roughly double. \n",
    "Round figure of 7 for kurtosis is reasonable, but when ten years is considered\n",
    "from 2007 to 2017 the overall kurtosis is about 13.5 since\n",
    "the extreme returns during the Great Recession is combined\n",
    "with compressed returns of the latter period.\n",
    "\n",
    "The analytics of leptokurtosis demonstrates that there is a\n",
    "small chance of double volatility lurking in financial returns every day."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "\n",
    "***Note on option pricing***: Models for option pricing usually assume\n",
    "logarithmic returns follow a Gaussian stochastic process, which by\n",
    "assumption sets Pearson kurtosis rigidly fixed to 3.\n",
    "By forecasting kurtosis during the life of an option,\n",
    "we can apply Gaussian mixture techniques to re-evaluate the standard model.\n",
    "The details will covered in a separate notebook."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "\n",
    "## Appendix 1: Confirm analytical results using simulation\n",
    "\n",
    "We now use our simulation module `nb/yi_simulation.py`\n",
    "with generic GM(2) specifications to see if our \"observed\" statistics\n",
    "$\\kappa$ and $\\sigma$ can be reproduced. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\u001b[0;31mSignature:\u001b[0m \u001b[0msimug_mix\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msigma1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msigma2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mq\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m0.1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mN\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m256\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
       "\u001b[0;31mSource:\u001b[0m   \n",
       "\u001b[0;32mdef\u001b[0m \u001b[0msimug_mix\u001b[0m\u001b[0;34m(\u001b[0m \u001b[0msigma1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msigma2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mq\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m0.10\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mN\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m256\u001b[0m \u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0;34m'''Simulate array from zero-mean Gaussian mixture GM(2).'''\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0;31m#     Mathematical details in nb/gauss-mix-kurtosis.ipynb\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0;31m#  Pre-populate an array of shape (N,) with the FIRST Gaussian,\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0;31m#  so that most work is done quickly and memory efficient...\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0marr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msimug\u001b[0m\u001b[0;34m(\u001b[0m \u001b[0msigma1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mN\u001b[0m \u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0;31m#     ... except for some random replacements:\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mN\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m        \u001b[0;31m#                p = 1-q = probability drawing from FIRST Gaussian.\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m        \u001b[0;31m#  So with probability q, replace an element of arr\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m        \u001b[0;31m#  with a float from the SECOND Gaussian:\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m        \u001b[0;32mif\u001b[0m \u001b[0mmaybe\u001b[0m\u001b[0;34m(\u001b[0m \u001b[0mq\u001b[0m \u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m            \u001b[0marr\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mrandog\u001b[0m\u001b[0;34m(\u001b[0m \u001b[0msigma2\u001b[0m \u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\n",
       "\u001b[0;34m\u001b[0m    \u001b[0;32mreturn\u001b[0m \u001b[0marr\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
       "\u001b[0;31mFile:\u001b[0m      ~/Dropbox/ipy/fecon235/lib/yi_simulation.py\n",
       "\u001b[0;31mType:\u001b[0m      function\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#  Here is the function for simulating zero-mean GM(2):\n",
    "simug_mix??"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                 Y\n",
      "count  2560.000000\n",
      "mean      0.005134\n",
      "std       0.131963\n",
      "min      -0.674101\n",
      "25%      -0.068051\n",
      "50%       0.006167\n",
      "75%       0.079101\n",
      "max       0.668929\n",
      "kurtosis  6.00261\n"
     ]
    }
   ],
   "source": [
    "#  Use XYZ example to generate sample array of GM(2) mixture:\n",
    "mix = simug_mix(sigma1=0.096896, sigma2=0.26, q=0.12903, N=2560)\n",
    "\n",
    "#  Show observed stats:\n",
    "stat(mix)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "By repeatedly executing the previous block,\n",
    "we see that sigma (standard deviation) is about 0.13\n",
    "as expected from our analytics,\n",
    "but the kurtosis can fluctuate. In small samples,\n",
    "the fourth power can show up looking like outliers.\n",
    "The count=2560 corresponds to ten years of daily data.\n",
    "\n",
    "So *what is kurtosis on average here?*\n",
    "This is a typical question asked of small-sample distributions.\n",
    "Let's collect some data from repeatedly running a simulation."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                 Y\n",
      "count  1000.000000\n",
      "mean      6.944915\n",
      "std       0.708962\n",
      "min       5.102336\n",
      "25%       6.455984\n",
      "50%       6.877510\n",
      "75%       7.365816\n",
      "max       9.790339\n",
      "kurtosis  3.711716\n"
     ]
    }
   ],
   "source": [
    "runs = 1000\n",
    "kurt_samples = np.zeros(runs)\n",
    "\n",
    "for i in range(runs):\n",
    "    mix = simug_mix(sigma1=0.096896, sigma2=0.26, q=0.12903, N=2560)\n",
    "    kurt_samples[i] = kurtfun(mix)\n",
    "    #                 kurtfun yields Pearson kurtosis \"kappa\"\n",
    "\n",
    "stat(kurt_samples)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "***On average, kurtosis from our experiment is about 7 as expected\n",
    "from the mathematical propositions.***\n",
    "In theory, kurtosis should converge to 7 as we increase N,\n",
    "the number of points per run, and as we increase the number\n",
    "of simulated runs.\n",
    "\n",
    "It is very interesting how much kurtosis can fluctuate depending\n",
    "on the particular sample: its std is about 0.7, so we can expect\n",
    "to observe kurtosis roughly between 5.6 to 8.4 when\n",
    "the true kurtosis is 7."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "\n",
    "## Appendix 2: Visualizing a non-Gaussian distribution\n",
    "\n",
    "It is helpful to *visualize* the mathematical results above.\n",
    "The most useful plot for non-Gaussian distributions is\n",
    "the **Quantile-Quantile** [Q-Q probability plot](https://en.wikipedia.org/wiki/Q–Q_plot).\n",
    "\n",
    "The default setting for our *plotqq()* procedure will\n",
    "graphically compare the distribution of observed data\n",
    "against a theoretical Normal distribution.\n",
    "Details are covered in module `lib/yi_plot.py`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
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SxbGGGOKZMnCGGNMkSxZGONGRBqKyJfOlOIbRGSkiFT08T66iUhnt+UBInKP83iciNzq\ny/0Z4wuWLIw52VRgqqq2BFoAYcD/+XgfMcBluQuqOkZVP/bxPozxKUsWxjhE5CrgsKp+CK6bhQBP\nAveKyKMi8o5b229EpKvz+D0R+Sn/DWRE5A8ReUlEljo35WopIk2Bh4EnRCRZRC4XkRdF5CkP/YkW\nkbki8rOIfCci9Zz1g5wb8qQ4V1AbU+ICbiJBY0rQBbhucJNHVQ+KSCoQQsFz/T/v3D++ApAoIlNU\ndaXzXLqqdhSRR3Dd0OkhERkNHFTVtyDvplYncSawewfXPGC7RaQv8ArwIPAsEKmqx4Ptbomm7LJk\nYcyZu1NE4nD9fzoHaAPkJosvnH+XArcUY5utgLbATBERXKMA253nlgMTRORL4Msz7LsxXrFkYcyf\nVgO3ua9wvrnXwzV5Y0u3p6o4z0cCfwU6OtM8j8t9zpE7O3A2xfv/JsBKVb3cw3M3Al2B3sA/RKSt\n2x0UjSkRVrMwxqGqiUBVtzOTQoA3cA0HpQJR4tIY1y1TAc7CdQ/qg05NwZtZcg86ryvMOqCuiHRy\n+hLqdmOaJqo6D3jO2U51L0M05rRZsjDmZLcAt4vIeiADyFbV11R1EfAHsAoYjlPbUNUVQAque6d8\nDCx021ZBNY5vgFtyC9z52qmz3eO4jnKGiUgKsAzo7NQyPhaR5U4fRqjqAR/EbUyhbIpyYwrgfKv/\nFLhFVVP83R9j/MmShTHGmCLZMJQxxpgiWbIwxhhTJEsWxhhjimTJwhhjTJEsWRhjjCmSJQtjjDFF\nsmRhjDGmSP8Pl8wXRqXRQ/sAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xa9aaf80c>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                Y\n",
      "count  256.000000\n",
      "mean    -0.022010\n",
      "std      0.142689\n",
      "min     -0.720196\n",
      "25%     -0.094655\n",
      "50%     -0.011186\n",
      "75%      0.063604\n",
      "max      0.511783\n",
      "kurtosis  7.51103\n"
     ]
    }
   ],
   "source": [
    "#  Generate GM(2) mixture, with unconstrained mean mu, and use\n",
    "#  parameters from XYZ example to generate a small sample array:\n",
    "mu = 0\n",
    "sigma = 0.13\n",
    "b = 2  # By construction, b > 1.\n",
    "mumix = mu + simug_mix(sigma1=0.096896, sigma2=b*sigma, q=0.12903, N=256)\n",
    "\n",
    "plotqq( mumix )\n",
    "stat( mumix )"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If the observed values truly came from a normal distribution,\n",
    "most of the plotted points should be along the solid green line.\n",
    "Points far from the line are usually identified as *outliers*, but\n",
    "for leptokurtotic distributions such points in the tails are to be expected.\n",
    "Statistical tests for normality are essentially testing\n",
    "deviations from the green line ($R^2$ shown within the plot\n",
    "derives from linear regression and should not be\n",
    "considered a serious test statistic).\n",
    "\n",
    "The last cell simulates a small-sample (N=256, say, one year of daily data)\n",
    "where kurtosis is exactly 7 in theory.\n",
    "***We highly recommend re-running the cell using different parameter values***,\n",
    "including unconstrained mean mu, **to visually understand\n",
    "how Q-Q plots can appear so vastly different in practice\n",
    "even when the generating dynamics are fully known**.\n",
    "When applying *plotqq()* to actual returns of financial assets,\n",
    "one should be able to recognize plots where a GM(2) model\n",
    "is appropriate.\n",
    "\n",
    "The *stat(mix)* output illustrates how much statistical estimates of a\n",
    "Gaussian mixture sample can differ from their theoretical values,\n",
    "especially when the sample size is small.\n",
    "Such variability is noteworthy when we base portfolio decisions\n",
    "on estimated statistics mistaken for being stable."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "\n",
    "##  Appendix 3: Fitting Gaussian mixtures using scikit-learn\n",
    "\n",
    "This notebook imposed structure on GM(2) to discern its\n",
    "parametric relationships in theory. From two observable statistics\n",
    "we deduced a reasonable shape for a Gaussian mixture\n",
    "stylized by actual financial returns.\n",
    "\n",
    "Given several assets, our plain $\\sigma$ must be generalized\n",
    "to a covariance matrix. Python via *scikit-learn* offers\n",
    "code to fit unconstrained mixtures.\n",
    "For starters, please see to http://scikit-learn.org/stable/modules/mixture.html\n",
    "\n",
    "Tiago Ramalho wrote a\n",
    "[quick introduction](http://www.nehalemlabs.net/prototype/blog/2014/04/03/quick-introduction-to-gaussian-mixture-models-with-python)\n",
    "to Gaussian mixture models with Python."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## References\n",
    "\n",
    "Cohen, A.C. (1967) Estimation in mixtures of two normal distributions.\n",
    "*Technometrika* 9:15–28.\n",
    "\n",
    "Pearson, K. (1894) Contributions to the theory of mathematical evolution.\n",
    "*Philosophical Trans. Roy. Soc. London* A185:71–110.\n",
    "\n",
    "Wang, Jin (2015), [Multivariate Mixtures of Normal Distributions: Properties, Random Vector Generation, Fitting, and as Models of Market Daily Changes](https://www.researchgate.net/profile/Jin_Wang40/publication/274695842_Multivariate_Mixtures_of_Normal_Distributions_Properties_Random_Vector_Generation_Fitting_and_as_Models_of_Market_Daily_Changes/links/5525314c0cf22e181e73ee4f.pdf), Journal on Computing, Vol. 27, No. 2, Spring 2015, pp. 193–203. Cf. earlier version, Wang (2000), [Modeling and Generating Daily Changes in Market Variables Using A Multivariate Mixture of Normal Distributions](http://ww2.valdosta.edu/~jwang/paper/MixNormal.pdf).\n",
    "\n",
    "Thanks for corrected [skew equation](http://onlyvix.blogspot.com/2011/05/mixture-of-normal-formulas-for-skew-and.html) to @onlyvixx, and jwang@valdosta.edu."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
