{"id":29164978,"url":"https://github.com/lrydin/jumpdiff","last_synced_at":"2025-07-01T07:08:45.472Z","repository":{"id":48054523,"uuid":"248468411","full_name":"LRydin/jumpdiff","owner":"LRydin","description":"JumpDiff: Non-parametric estimator for Jump-diffusion processes for Python","archived":false,"fork":false,"pushed_at":"2023-02-10T12:05:49.000Z","size":627,"stargazers_count":47,"open_issues_count":1,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-30T13:21:21.840Z","etag":null,"topics":["conditional-moments","diffusion-term","estimator","jump-amplitude","jump-diffusion","jump-rate","kramers-moyal","non-parametric","python","stochastic-processes"],"latest_commit_sha":null,"homepage":"","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/LRydin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-03-19T10:01:38.000Z","updated_at":"2025-06-29T21:56:50.000Z","dependencies_parsed_at":"2023-01-22T04:08:19.729Z","dependency_job_id":"a456a617-c672-439a-af1c-5b7de67d107c","html_url":"https://github.com/LRydin/jumpdiff","commit_stats":{"total_commits":77,"total_committers":2,"mean_commits":38.5,"dds":"0.012987012987012991","last_synced_commit":"8f5e9fdbc223c70b37ccff09a80d738a052f6b44"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/LRydin/jumpdiff","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LRydin%2Fjumpdiff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LRydin%2Fjumpdiff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LRydin%2Fjumpdiff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LRydin%2Fjumpdiff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LRydin","download_url":"https://codeload.github.com/LRydin/jumpdiff/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LRydin%2Fjumpdiff/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262916681,"owners_count":23383889,"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":["conditional-moments","diffusion-term","estimator","jump-amplitude","jump-diffusion","jump-rate","kramers-moyal","non-parametric","python","stochastic-processes"],"created_at":"2025-07-01T07:08:43.862Z","updated_at":"2025-07-01T07:08:45.449Z","avatar_url":"https://github.com/LRydin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![PyPI - License](https://img.shields.io/pypi/l/jumpdiff)\n![PyPI](https://img.shields.io/pypi/v/jumpdiff)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/jumpdiff)\n[![Build Status](https://github.com/LRydin/jumpdiff/actions/workflows/CI.yml/badge.svg)](https://github.com/LRydin/jumpdiff/actions/workflows/CI.yml)\n[![codecov](https://codecov.io/gh/LRydin/jumpdiff/branch/master/graph/badge.svg)](https://codecov.io/gh/LRydin/jumpdiff)\n[![Documentation Status](https://readthedocs.org/projects/jumpdiff/badge/?version=latest)](https://jumpdiff.readthedocs.io/en/latest/?badge=latest)\n\n# jumpdiff\n`jumpdiff` is a `python` library with non-parametric Nadaraya─Watson estimators to extract the parameters of jump-diffusion processes.\nWith `jumpdiff` one can extract the parameters of a jump-diffusion process from one-dimensional timeseries, employing both a kernel-density estimation method combined with a set on second-order corrections for a precise retrieval of the parameters for short timeseries.\n\n## Installation\nTo install `jumpdiff`, run\n\n```\n   pip install jumpdiff\n```\n\nThen on your favourite editor just use\n\n```python\n   import jumpdiff as jd\n```\n\n## Dependencies\nThe library parameter estimation depends on `numpy` and `scipy` solely. The mathematical formulae depend on `sympy`. It stems from [`kramersmoyal`](https://github.com/LRydin/KramersMoyal) project, but functions independently from it\u003csup\u003e3\u003c/sup\u003e.\n\n## Documentation\nYou can find the documentation [here](https://jumpdiff.readthedocs.io/).\n\n# Jump-diffusion processes\n## The theory\nJump-diffusion processes\u003csup\u003e1\u003c/sup\u003e, as the name suggest, are a mixed type of stochastic processes with a diffusive and a jump term.\nOne form of these processes which is mathematically traceable is given by the [Stochastic Differential Equation](https://en.wikipedia.org/wiki/Stochastic_differential_equation)\n\n\u003cimg src=\"/Others/SDE_1.png\" title=\"A jump diffusion process\" height=\"25\"/\u003e\n\nwhich has 4 main elements: a drift term \u003cimg src=\"/Others/a_xt.png\" title=\"drift term\" height=\"18\"/\u003e, a diffusion term \u003cimg src=\"/Others/b_xt.png\" title=\"diffusion term\" height=\"18\"/\u003e, and jump amplitude term \u003cimg src=\"/Others/xi.png\" title=\"jump amplitude term\" height=\"18\"/\u003e, which is given by a Gaussian distribution, and finally a jump rate \u003cimg src=\"/Others/lambda.png\" title=\"jump rate term\" height=\"14\"/\u003e.\nYou can find a good review on this topic in Ref. 2.\n\n## Integrating a jump-diffusion process\nLet us use the functions in `jumpdiff` to generate a jump-difussion process, and subsequently retrieve the parameters. This is a good way to understand the usage of the integrator and the non-parametric retrieval of the parameters.\n\nFirst we need to load our library. We will call it `jd`\n```python\nimport jumpdiff as jd\n```\nLet us thus define a jump-diffusion process and use `jd_process` to integrate it. Do notice here that we need the drift \u003cimg src=\"/Others/a_xt.png\" title=\"drift term\" height=\"18\"/\u003e and diffusion \u003cimg src=\"/Others/b_xt.png\" title=\"diffusion term\" height=\"18\"/\u003e as functions.\n\n```python\n# integration time and time sampling\nt_final = 10000\ndelta_t = 0.001\n\n# A drift function\ndef a(x):\n    return -0.5*x\n\n# and a (constant) diffusion term\ndef b(x):\n    return 0.75\n\n# Now define a jump amplitude and rate\nxi = 2.5\nlamb = 1.75\n\n# and simply call the integration function\nX = jd.jd_process(t_final, delta_t, a=a, b=b, xi=xi, lamb=lamb)\n```\n\nThis will generate a jump diffusion process `X` of length `int(10000/0.001)` with the given parameters.\n\n\u003cimg src=\"/Others/X_trajectory.png\" title=\"A jump-difussion process\" height=\"200\"/\u003e\n\n## Using `jumpdiff` to retrieve the parameters\n### Moments and Kramers─Moyal coefficients\nTake the timeseries `X` and use the function `moments` to retrieve the conditional moments of the process.\nFor now let us focus on the shortest time lag, so we can best approximate the Kramers─Moyal coefficients.\nFor this case we can simply employ\n\n```python\nedges, moments = jd.moments(timeseries = X)\n```\nIn the array `edges` are the limits of our space, and in our array `moments` are recorded all 6 powers/order of our conditional moments.\nLet us take a look at these before we proceed, to get acquainted with them.\n\nWe can plot the first moment with any conventional plotter, so lets use here `plotly` from `matplotlib`\n\n```python\nimport matplotlib.plotly as plt\n\n# we want the first power, so we need 'moments[1,...]'\nplt.plot(edges, moments[1,...])\n```\nThe first moment here (i.e., the first Kramers─Moyal coefficient) is given solely by the drift term that we have selected `-0.5*x`\n\n\u003cimg src=\"/Others/1_moment.png\" title=\"The 1st Kramers─Moyal coefficient\" height=\"200\"/\u003e\n\nAnd the second moment (i.e., the second Kramers─Moyal coefficient) is a mixture of both the contributions of the diffusive term \u003cimg src=\"/Others/b_xt.png\" title=\"diffusion term\" height=\"18\"/\u003e and the jump terms \u003cimg src=\"/Others/xi.png\" title=\"jump amplitude term\" height=\"18\"/\u003e and \u003cimg src=\"/Others/lambda.png\" title=\"jump rate term\" height=\"14\"/\u003e.\n\n\u003cimg src=\"/Others/2_moment.png\" title=\"The 2nd Kramers─Moyal coefficient\" height=\"200\"/\u003e\n\nYou have this stored in `moments[2,...]`.\n\n### Retrieving the jump-related terms\nNaturally one of the most pertinent questions when addressing jump-diffusion processes is the possibility of recovering these same parameters from data. For the given jump-diffusion process we can use the `jump_amplitude` and `jump_rate` functions to non-parametrically estimate the jump amplitude \u003cimg src=\"/Others/xi.png\" title=\"jump amplitude term\" height=\"18\"/\u003e and jump rate \u003cimg src=\"/Others/lambda.png\" title=\"jump rate term\" height=\"18\"/\u003e terms.\n\nAfter having the `moments` in hand, all we need is\n\n```python\n# first estimate the jump amplitude\nxi_est = jd.jump_amplitude(moments = moments)\n\n# and now estimated the jump rate\nlamb_est = jd.jump_rate(moments = moments)\n```\nwhich resulted in our case in `(xi_est) ξ = 2.43 ± 0.17` and `(lamb_est) λ = 1.744 * delta_t` (don't forget to divide `lamb_est` by `delta_t`)!\n\n### Other functions and options\nInclude in this package is also the [Milstein scheme](https://en.wikipedia.org/wiki/Milstein_method) of integration, particularly important when the diffusion term has some spacial `x` dependence. `moments` can actually calculate the conditional moments for different lags, using the parameter `lag`.\n\nIn `formulae` the set of formulas needed to calculate the second order corrections are given (in `sympy`).\n\n# Contributions\nWe welcome reviews and ideas from everyone. If you want to share your ideas, upgrades, doubts, or simply report a bug, open an [issue](https://github.com/LRydin/jumpdiff/issues) here on GitHub, or contact us directly.\nIf you need help with the code, the theory, or the implementation, drop us an email.\nWe abide to a [Conduct of Fairness](contributions.md).\n\n# Changelog\n- Version 0.4 - Designing a set of self-consistency checks, the documentation, examples, and a trial code. Code at PyPi.\n- Version 0.3 - Designing a straightforward procedure to retrieve the jump amplitude and jump rate functions, alongside with a easy `sympy` displaying the correction.\n- Version 0.2 - Introducing the second-order corrections to the moments\n- Version 0.1 - Design an implementation of the `moments` functions, generalising `kramersmoyal` `km`.\n\n# Literature and Support\n\n### History\nThis project was started in 2017 at the [neurophysik](https://www.researchgate.net/lab/Klaus-Lehnertz-Lab-2) by Leonardo Rydin Gorjão, Jan Heysel, Klaus Lehnertz, and M. Reza Rahimi Tabar, and separately by Pedro G. Lind, at the Department of Computer Science, Oslo Metropolitan University. From 2019 to 2021, Pedro G. Lind, Leonardo Rydin Gorjão, and Dirk Witthaut developed a set of corrections and an implementation for python, presented here.\n\n### Funding\nHelmholtz Association Initiative _Energy System 2050 - A Contribution of the Research Field Energy_ and the grant No. VH-NG-1025 and *STORM - Stochastics for Time-Space Risk Models* project of the Research Council of Norway (RCN) No. 274410.\n\n---\n##### Bibliography\n\n\u003csup\u003e1\u003c/sup\u003e Tabar, M. R. R. *Analysis and Data-Based Reconstruction of Complex Nonlinear Dynamical Systems.* Springer, International Publishing (2019), Chapter [*Stochastic Processes with Jumps and Non-vanishing Higher-Order Kramers–Moyal Coefficients*](https://doi.org/10.1007/978-3-030-18472-8_11).\n\n\u003csup\u003e2\u003c/sup\u003e Friedrich, R., Peinke, J., Sahimi, M., Tabar, M. R. R. *Approaching complexity by stochastic methods: From biological systems to turbulence,* [Physics Reports 506, 87–162 (2011)](https://doi.org/10.1016/j.physrep.2011.05.003).\n\n\u003csup\u003e3\u003c/sup\u003e Rydin Gorjão, L., Meirinhos, F. *kramersmoyal: Kramers–Moyal coefficients for stochastic processes.* [Journal of Open Source Software, **4**(44) (2019)](https://doi.org/10.21105/joss.01693).\n\n##### Extended Literature\nYou can find further reading on SDE, non-parametric estimatons, and the general principles of the Fokker–Planck equation, Kramers–Moyal expansion, and related topics in the classic (physics) books\n\n- Risken, H. *The Fokker–Planck equation.* Springer, Berlin, Heidelberg (1989).\n- Gardiner, C.W. *Handbook of Stochastic Methods.* Springer, Berlin (1985).\n\nAnd an extensive review on the subject [here](http://sharif.edu/~rahimitabar/pdfs/80.pdf)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flrydin%2Fjumpdiff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flrydin%2Fjumpdiff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flrydin%2Fjumpdiff/lists"}