{"id":13689300,"url":"https://github.com/crflynn/stochastic","last_synced_at":"2025-05-16T03:06:57.435Z","repository":{"id":37484118,"uuid":"82245607","full_name":"crflynn/stochastic","owner":"crflynn","description":"Generate realizations of stochastic processes in python.","archived":false,"fork":false,"pushed_at":"2022-12-09T06:43:37.000Z","size":3909,"stargazers_count":473,"open_issues_count":14,"forks_count":86,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-05-13T10:19:14.974Z","etag":null,"topics":["probability","stochastic","stochastic-differential-equations","stochastic-processes","stochastic-simulation-algorithm","stochastic-volatility-models"],"latest_commit_sha":null,"homepage":"http://stochastic.readthedocs.io/en/stable/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/crflynn.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-17T01:54:16.000Z","updated_at":"2025-04-14T16:02:00.000Z","dependencies_parsed_at":"2023-01-25T17:01:34.877Z","dependency_job_id":null,"html_url":"https://github.com/crflynn/stochastic","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crflynn%2Fstochastic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crflynn%2Fstochastic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crflynn%2Fstochastic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crflynn%2Fstochastic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crflynn","download_url":"https://codeload.github.com/crflynn/stochastic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254459088,"owners_count":22074605,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["probability","stochastic","stochastic-differential-equations","stochastic-processes","stochastic-simulation-algorithm","stochastic-volatility-models"],"created_at":"2024-08-02T15:01:41.897Z","updated_at":"2025-05-16T03:06:52.422Z","avatar_url":"https://github.com/crflynn.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"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–Maruyama 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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrflynn%2Fstochastic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrflynn%2Fstochastic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrflynn%2Fstochastic/lists"}