{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Generating GLE Samples\n\nGeneration of sample trajectory via :class:`GLE_analysisEM.GLE_Estimator.sample`\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import numpy as np\nfrom matplotlib import pyplot as plt\nfrom GLE_analysisEM import GLE_Estimator, GLE_BasisTransform\nfrom sklearn.preprocessing import FunctionTransformer\n\n\na = 0.025\nb = 1.0\n\n\ndef dV(X):\n    \"\"\"\n    Compute the force field\n    \"\"\"\n    return -4 * a * np.power(X, 3) + 2 * b * X\n\n\ndim_x = 1\ndim_h = 1\nmodel = \"euler\"\nforce = np.identity(dim_x)\n\nbasis = GLE_BasisTransform(transformer=FunctionTransformer(dV))\ngenerator = GLE_Estimator(verbose=1, dim_x=dim_x, dim_h=dim_h, model=model, basis=basis, force_init=force, init_params=\"random\", multiprocessing=4)\nX, idx, h = generator.sample(n_samples=5000, x0=0.0, v0=0.0)\nprint(generator.get_coefficients())\nfor n in range(dim_h):\n    plt.plot(X[:, 0], h[:, n], label=\"h{}\".format(n + 1))\n\nfor n in range(dim_x):\n    plt.plot(X[:, 0], X[:, n * 2 + 2], label=\"v{}\".format(n + 1))\n    plt.plot(X[:, 0], X[:, n * 2 + 1], label=\"x{}\".format(n + 1))\n\n\nplt.legend(loc=\"upper right\")\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.9.7"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}