stochastic


Namestochastic JSON
Version 0.7.0 PyPI version JSON
download
home_pagehttps://github.com/crflynn/stochastic
SummaryGenerate realizations of stochastic processes
upload_time2022-07-12 03:23:01
maintainer
docs_urlNone
authorFlynn
requires_python>=3.8,<3.11
licenseMIT
keywords stochastic processes
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            stochastic
==========

|build| |rtd| |codecov| |pypi| |pyversions|

.. |build| image:: https://github.com/crflynn/stochastic/actions/workflows/build.yml/badge.svg
    :target: https://github.com/crflynn/stochastic/actions

.. |rtd| image:: https://img.shields.io/readthedocs/stochastic.svg
    :target: http://stochastic.readthedocs.io/en/latest/

.. |codecov| image:: https://codecov.io/gh/crflynn/stochastic/branch/master/graphs/badge.svg
    :target: https://codecov.io/gh/crflynn/stochastic

.. |pypi| image:: https://img.shields.io/pypi/v/stochastic.svg
    :target: https://pypi.python.org/pypi/stochastic

.. |pyversions| image:: https://img.shields.io/pypi/pyversions/stochastic.svg
    :target: https://pypi.python.org/pypi/stochastic


A python package for generating realizations of stochastic processes.

Installation
------------

The ``stochastic`` package is available on pypi and can be installed using pip

.. code-block:: shell

    pip install stochastic

Dependencies
~~~~~~~~~~~~

Stochastic uses ``numpy`` for many calculations and ``scipy`` for sampling
specific random variables.

Processes
---------

This package offers a number of common discrete-time, continuous-time, and
noise process objects for generating realizations of stochastic processes as
``numpy`` arrays.

The diffusion processes are approximated using the Euler–Maruyama method.

Here are the currently supported processes and their class references within
the package.

* stochastic.processes

    * continuous

        * BesselProcess
        * BrownianBridge
        * BrownianExcursion
        * BrownianMeander
        * BrownianMotion
        * CauchyProcess
        * FractionalBrownianMotion
        * GammaProcess
        * GeometricBrownianMotion
        * InverseGaussianProcess
        * MixedPoissonProcess
        * MultifractionalBrownianMotion
        * PoissonProcess
        * SquaredBesselProcess
        * VarianceGammaProcess
        * WienerProcess

    * diffusion

        * DiffusionProcess (generalized)
        * ConstantElasticityVarianceProcess
        * CoxIngersollRossProcess
        * ExtendedVasicekProcess
        * OrnsteinUhlenbeckProcess
        * VasicekProcess

    * discrete

        * BernoulliProcess
        * ChineseRestaurantProcess
        * DirichletProcess
        * MarkovChain
        * MoranProcess
        * RandomWalk

    * noise

        * BlueNoise
        * BrownianNoise
        * ColoredNoise
        * PinkNoise
        * RedNoise
        * VioletNoise
        * WhiteNoise
        * FractionalGaussianNoise
        * GaussianNoise

Usage patterns
--------------

Sampling
~~~~~~~~

To use ``stochastic``, import the process you want and instantiate with the
required parameters. Every process class has a ``sample`` method for generating
realizations. The ``sample`` methods accept a parameter ``n`` for the quantity
of steps in the realization, but others (Poisson, for instance) may take
additional parameters. Parameters can be accessed as attributes of the
instance.

.. code-block:: python

    from stochastic.processes.discrete import BernoulliProcess


    bp = BernoulliProcess(p=0.6)
    s = bp.sample(16)
    success_probability = bp.p


Continuous processes provide a default parameter, ``t``, which indicates the
maximum time of the process realizations. The default value is 1. The sample
method will generate ``n`` equally spaced increments on the
interval ``[0, t]``.

Sampling at specific times
~~~~~~~~~~~~~~~~~~~~~~~~~~

Some continuous processes also provide a ``sample_at()`` method, in which a
sequence of time values can be passed at which the object will generate a
realization. This method ignores the parameter, ``t``, specified on
instantiation.


.. code-block:: python

    from stochastic.processes.continuous import BrownianMotion


    bm = BrownianMotion(drift=1, scale=1, t=1)
    times = [0, 3, 10, 11, 11.2, 20]
    s = bm.sample_at(times)

Sample times
~~~~~~~~~~~~

Continuous processes also provide a method ``times()`` which generates the time
values (using ``numpy.linspace``) corresponding to a realization of ``n``
steps. This is particularly useful for plotting your samples.


.. code-block:: python

    import matplotlib.pyplot as plt
    from stochastic.processes.continuous import FractionalBrownianMotion


    fbm = FractionalBrownianMotion(hurst=0.7, t=1)
    s = fbm.sample(32)
    times = fbm.times(32)

    plt.plot(times, s)
    plt.show()


Specifying an algorithm
~~~~~~~~~~~~~~~~~~~~~~~

Some processes provide an optional parameter ``algorithm``, in which one can
specify which algorithm to use to generate the realization using the
``sample()`` or ``sample_at()`` methods. See the documentation for
process-specific implementations.


.. code-block:: python

    from stochastic.processes.noise import FractionalGaussianNoise


    fgn = FractionalGaussianNoise(hurst=0.6, t=1)
    s = fgn.sample(32, algorithm='hosking')

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/crflynn/stochastic",
    "name": "stochastic",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<3.11",
    "maintainer_email": "",
    "keywords": "stochastic,processes",
    "author": "Flynn",
    "author_email": "crf204@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f0/8f/487894eeb36fff56b4675a1e77242fea0f56bc1632aa56de53b9bc502964/stochastic-0.7.0.tar.gz",
    "platform": null,
    "description": "stochastic\n==========\n\n|build| |rtd| |codecov| |pypi| |pyversions|\n\n.. |build| image:: https://github.com/crflynn/stochastic/actions/workflows/build.yml/badge.svg\n    :target: https://github.com/crflynn/stochastic/actions\n\n.. |rtd| image:: https://img.shields.io/readthedocs/stochastic.svg\n    :target: http://stochastic.readthedocs.io/en/latest/\n\n.. |codecov| image:: https://codecov.io/gh/crflynn/stochastic/branch/master/graphs/badge.svg\n    :target: https://codecov.io/gh/crflynn/stochastic\n\n.. |pypi| image:: https://img.shields.io/pypi/v/stochastic.svg\n    :target: https://pypi.python.org/pypi/stochastic\n\n.. |pyversions| image:: https://img.shields.io/pypi/pyversions/stochastic.svg\n    :target: https://pypi.python.org/pypi/stochastic\n\n\nA python package for generating realizations of stochastic processes.\n\nInstallation\n------------\n\nThe ``stochastic`` package is available on pypi and can be installed using pip\n\n.. code-block:: shell\n\n    pip install stochastic\n\nDependencies\n~~~~~~~~~~~~\n\nStochastic uses ``numpy`` for many calculations and ``scipy`` for sampling\nspecific random variables.\n\nProcesses\n---------\n\nThis package offers a number of common discrete-time, continuous-time, and\nnoise process objects for generating realizations of stochastic processes as\n``numpy`` arrays.\n\nThe diffusion processes are approximated using the Euler\u2013Maruyama method.\n\nHere are the currently supported processes and their class references within\nthe package.\n\n* stochastic.processes\n\n    * continuous\n\n        * BesselProcess\n        * BrownianBridge\n        * BrownianExcursion\n        * BrownianMeander\n        * BrownianMotion\n        * CauchyProcess\n        * FractionalBrownianMotion\n        * GammaProcess\n        * GeometricBrownianMotion\n        * InverseGaussianProcess\n        * MixedPoissonProcess\n        * MultifractionalBrownianMotion\n        * PoissonProcess\n        * SquaredBesselProcess\n        * VarianceGammaProcess\n        * WienerProcess\n\n    * diffusion\n\n        * DiffusionProcess (generalized)\n        * ConstantElasticityVarianceProcess\n        * CoxIngersollRossProcess\n        * ExtendedVasicekProcess\n        * OrnsteinUhlenbeckProcess\n        * VasicekProcess\n\n    * discrete\n\n        * BernoulliProcess\n        * ChineseRestaurantProcess\n        * DirichletProcess\n        * MarkovChain\n        * MoranProcess\n        * RandomWalk\n\n    * noise\n\n        * BlueNoise\n        * BrownianNoise\n        * ColoredNoise\n        * PinkNoise\n        * RedNoise\n        * VioletNoise\n        * WhiteNoise\n        * FractionalGaussianNoise\n        * GaussianNoise\n\nUsage patterns\n--------------\n\nSampling\n~~~~~~~~\n\nTo use ``stochastic``, import the process you want and instantiate with the\nrequired parameters. Every process class has a ``sample`` method for generating\nrealizations. The ``sample`` methods accept a parameter ``n`` for the quantity\nof steps in the realization, but others (Poisson, for instance) may take\nadditional parameters. Parameters can be accessed as attributes of the\ninstance.\n\n.. code-block:: python\n\n    from stochastic.processes.discrete import BernoulliProcess\n\n\n    bp = BernoulliProcess(p=0.6)\n    s = bp.sample(16)\n    success_probability = bp.p\n\n\nContinuous processes provide a default parameter, ``t``, which indicates the\nmaximum time of the process realizations. The default value is 1. The sample\nmethod will generate ``n`` equally spaced increments on the\ninterval ``[0, t]``.\n\nSampling at specific times\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nSome continuous processes also provide a ``sample_at()`` method, in which a\nsequence of time values can be passed at which the object will generate a\nrealization. This method ignores the parameter, ``t``, specified on\ninstantiation.\n\n\n.. code-block:: python\n\n    from stochastic.processes.continuous import BrownianMotion\n\n\n    bm = BrownianMotion(drift=1, scale=1, t=1)\n    times = [0, 3, 10, 11, 11.2, 20]\n    s = bm.sample_at(times)\n\nSample times\n~~~~~~~~~~~~\n\nContinuous processes also provide a method ``times()`` which generates the time\nvalues (using ``numpy.linspace``) corresponding to a realization of ``n``\nsteps. This is particularly useful for plotting your samples.\n\n\n.. code-block:: python\n\n    import matplotlib.pyplot as plt\n    from stochastic.processes.continuous import FractionalBrownianMotion\n\n\n    fbm = FractionalBrownianMotion(hurst=0.7, t=1)\n    s = fbm.sample(32)\n    times = fbm.times(32)\n\n    plt.plot(times, s)\n    plt.show()\n\n\nSpecifying an algorithm\n~~~~~~~~~~~~~~~~~~~~~~~\n\nSome processes provide an optional parameter ``algorithm``, in which one can\nspecify which algorithm to use to generate the realization using the\n``sample()`` or ``sample_at()`` methods. See the documentation for\nprocess-specific implementations.\n\n\n.. code-block:: python\n\n    from stochastic.processes.noise import FractionalGaussianNoise\n\n\n    fgn = FractionalGaussianNoise(hurst=0.6, t=1)\n    s = fgn.sample(32, algorithm='hosking')\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Generate realizations of stochastic processes",
    "version": "0.7.0",
    "project_urls": {
        "Documentation": "https://stochastic.readthedocs.io/en/latest/",
        "Homepage": "https://github.com/crflynn/stochastic",
        "Repository": "https://github.com/crflynn/stochastic"
    },
    "split_keywords": [
        "stochastic",
        "processes"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eec5b0eeb721c07f634ad7fdf9bfc8d397eb5af1150f922fc7620f282f1af5bb",
                "md5": "ae9a4e2700bf51af1f753bbc1043a46e",
                "sha256": "b39b807886b9e92b7cba2848e85629cc07bab964f87a3317168b6b9de2e3394f"
            },
            "downloads": -1,
            "filename": "stochastic-0.7.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ae9a4e2700bf51af1f753bbc1043a46e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<3.11",
            "size": 48057,
            "upload_time": "2022-07-12T03:23:00",
            "upload_time_iso_8601": "2022-07-12T03:23:00.136148Z",
            "url": "https://files.pythonhosted.org/packages/ee/c5/b0eeb721c07f634ad7fdf9bfc8d397eb5af1150f922fc7620f282f1af5bb/stochastic-0.7.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f08f487894eeb36fff56b4675a1e77242fea0f56bc1632aa56de53b9bc502964",
                "md5": "c7ce74d4efc6050e8a4f097284b7fc3d",
                "sha256": "c166b5f7707d0857597125dbffa03f59cb1ffb668cb027396d4cca69b3df1b7b"
            },
            "downloads": -1,
            "filename": "stochastic-0.7.0.tar.gz",
            "has_sig": false,
            "md5_digest": "c7ce74d4efc6050e8a4f097284b7fc3d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<3.11",
            "size": 28251,
            "upload_time": "2022-07-12T03:23:01",
            "upload_time_iso_8601": "2022-07-12T03:23:01.938719Z",
            "url": "https://files.pythonhosted.org/packages/f0/8f/487894eeb36fff56b4675a1e77242fea0f56bc1632aa56de53b9bc502964/stochastic-0.7.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-07-12 03:23:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "crflynn",
    "github_project": "stochastic",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "lcname": "stochastic"
}
        
Elapsed time: 0.29793s