{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Spectral methods\n\nThe spectrum of a covariance model is given by:\n\n\\begin{align}S(\\mathbf{k}) = \\left(\\frac{1}{2\\pi}\\right)^n\n    \\int C(\\Vert\\mathbf{r}\\Vert) e^{i b\\mathbf{k}\\cdot\\mathbf{r}} d^n\\mathbf{r}\\end{align}\n\nSince the covariance function $C(r)$ is radially symmetric, we can\ncalculate this by the\n`hankel-transformation <https://en.wikipedia.org/wiki/Hankel_transform>`_:\n\n\\begin{align}S(k) = \\left(\\frac{1}{2\\pi}\\right)^n \\cdot\n    \\frac{(2\\pi)^{n/2}}{(bk)^{n/2-1}}\n    \\int_0^\\infty r^{n/2-1} C(r) J_{n/2-1}(bkr) r dr\\end{align}\n\nWhere $k=\\left\\Vert\\mathbf{k}\\right\\Vert$.\n\nDepending on the spectrum, the spectral-density is defined by:\n\n\\begin{align}\\tilde{S}(k) = \\frac{S(k)}{\\sigma^2}\\end{align}\n\nYou can access these methods by:\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import gstools as gs\n\nmodel = gs.Gaussian(dim=3, var=2.0, len_scale=10)\nax = model.plot(\"spectrum\")\nmodel.plot(\"spectral_density\", ax=ax)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "<div class=\"alert alert-info\"><h4>Note</h4><p>The spectral-density is given by the radius of the input phase. But it is\n   **not** a probability density function for the radius of the phase.\n   To obtain the pdf for the phase-radius, you can use the methods\n   :any:`CovModel.spectral_rad_pdf`\n   or :any:`CovModel.ln_spectral_rad_pdf` for the logarithm.\n\n   The user can also provide a cdf (cumulative distribution function) by\n   defining a method called ``spectral_rad_cdf``\n   and/or a ppf (percent-point function)\n   by ``spectral_rad_ppf``.\n\n   The attributes :any:`CovModel.has_cdf`\n   and :any:`CovModel.has_ppf` will check for that.</p></div>\n\n"
      ]
    }
  ],
  "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.9"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}