Coder Social home page Coder Social logo

quantgirluk / aleatory Goto Github PK

View Code? Open in Web Editor NEW
119.0 5.0 10.0 84.99 MB

📦 Python library for Stochastic Processes Simulation and Visualisation

License: MIT License

Python 100.00%
data-visualization data-viz monte-carlo probability statistics stochastic-processes diffusion-models financial-mathematics stochastic-differential-equations

aleatory's Introduction

aleatory

PyPI version fury.io Downloads

example workflow Documentation Status

Overview

The aleatory (/ˈeɪliətəri/) Python library provides functionality for simulating and visualising stochastic processes. More precisely, it introduces objects representing a number of continuous-time stochastic processes $X = (X_t : t\geq 0)$ and provides methods to:

  • generate realizations/trajectories from each process —over discrete time sets
  • create visualisations to illustrate the processes properties and behaviour

Currently, aleatory supports the following processes:

  • Brownian Motion
  • Brownian Bridge
  • Brownian Excursion
  • Brownian Meander
  • Geometric Brownian Motion
  • Ornstein–Uhlenbeck
  • Vasicek
  • Cox–Ingersoll–Ross
  • Constant Elasticity
  • Bessel Process
  • Squared Bessel Processs

Installation

Aleatory is available on pypi and can be installed as follows

pip install aleatory

Dependencies

Aleatory relies heavily on

  • numpy for random number generation
  • scipy and statsmodels for support for a number of one-dimensional distributions.
  • matplotlib for creating visualisations

Compatibility

Aleatory is tested on Python versions 3.8, 3.9, 3.10, and 3.11

Quick-Start

Aleatory allows you to create fancy visualisations from different stochastic processes in an easy and concise way.

For example, the following code

from aleatory.processes import BrownianMotion

brownian = BrownianMotion()
brownian.draw(n=100, N=100, colormap="cool", figsize=(12,9))

generates a chart like this:

For more examples visit the Quick-Start Guide.

If you like this project, please give it a star! ⭐️

Thanks for Visiting! ✨

Connect with me via:

aleatory's People

Contributors

quantgirluk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

aleatory's Issues

Paths fail to plot when there is only 1 histogram bin

Very nice package! I'm learning stochastic calculus and this is a really cool tool!

I found a small bug:
The paths plotted by SPExplicit.draw() are colored to match the histogram bin that their final point falls into.
If we plot N=3 or fewer paths, then we set n_bins = int(np.sqrt(N)) <= 1, and then this logic which helps set the path colors:

bin_centers = 0.5 * (bins[:-1] + bins[1:])
col = bin_centers - min(bin_centers)  # scale values to interval [0,1]
col /= max(col)

results in a divide by zero

/Users/alexrubin/code/aleatory/aleatory/utils/utils.py:76: RuntimeWarning: invalid value encountered in divide
    col /= max(col)

because col == [0.].

image

It seems like the 3 lines of logic above could be replaced by col = np.linspace(0, 1, n_bins, endpoint=True).

multivariate support in aleatory?

Hi there -

Very impressive package and thank you for making public!

I had an enhancement question.

Was curious if this package is planned to support multivariate processes? If I say have X commodities following various processes, with correlated random shocks.

Say two commodities, define one as GBM and the other as UO, with 70% correlation in their random draw direction. Is something like this currently feasible or something in the future plans?

My background in stochastic processes is in R, and can only point to MASS::mvrnorm as an example of the correlated draws.

Cheers!

Mistake in Vasicek definition?

Hi, I liked your package, thank you!

I believe there is a mistake in the Vasicek function

def g(x, _): return self.sigma

It should be

def g(x, _): return self.sigma * x

right?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.