{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Using the pyLFI Prior class\nExample usage of the `.Prior` class.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\nimport numpy as np\nimport pylfi"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "We initialize a Gaussian prior over the parameter $\\theta$. The first\npositional argument can be any `scipy.stats` distribution passed as `str`.\nFollowing positional and keyword arguments are distribution specific\n(see `scipy.stats` documentation). The `name` keyword argument is required\nand expects the name of the parameter passed as `str`. The optional `tex`\nkeyword argument can be used to provide LaTeX typesetting for the parameter\nname, which is used as axis label in `pyLFI`'s plotting procedures if\nprovided.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "theta_prior = pylfi.Prior('norm',\n                          loc=0,\n                          scale=1,\n                          name='theta',\n                          tex=r'$\\theta$'\n                          )"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Sampling from the prior is done through the `.rvs` method. The `size` keyword\ncan be used to set the output size of the sample. The sampling can also be\nseeded through the `seed` keyword argument.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "theta_prior.rvs(size=10, seed=42)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "The `~.plot_prior` method plots the prior pdf or pmf, depending on whether\nthe distribution is continuous or discrete, respectively, evaluated at points\n$x$.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "x = np.linspace(-4, 4, 1000)\ntheta_prior.plot_prior(x)"
      ]
    }
  ],
  "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.8.6"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}