{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Piecewise Aggregate Approximation\n\n\nThis example shows how you can approximate a time series using\n:class:`pyts.approximation.PiecewiseAggregateApproximation`.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import numpy as np\nimport matplotlib.pyplot as plt\nfrom pyts.approximation import PiecewiseAggregateApproximation\n\n# Parameters\nn_samples, n_timestamps = 100, 48\n\n# Toy dataset\nrng = np.random.RandomState(41)\nX = rng.randn(n_samples, n_timestamps)\n\n# PAA transformation\nwindow_size = 6\npaa = PiecewiseAggregateApproximation(window_size=window_size)\nX_paa = paa.transform(X)\n\n# Show the results for the first time series\nplt.figure(figsize=(12, 8))\nplt.plot(X[0], 'o--', label='Original')\nplt.plot(np.arange(window_size // 2,\n                   n_timestamps + window_size // 2,\n                   window_size), X_paa[0], 'o--', label='PAA')\nplt.vlines(np.arange(0, n_timestamps, window_size) - 0.5,\n           X[0].min(), X[0].max(), color='g', linestyles='--', linewidth=0.5)\nplt.legend(loc='best', fontsize=14)\nplt.show()"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.7.3"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}