Skip to content

Commit

Permalink
Merge pull request #16 from LRydin/dev
Browse files Browse the repository at this point in the history
Bumping to version 0.4.1
  • Loading branch information
LRydin authored Aug 25, 2023
2 parents 57a64ee + 145c40b commit 0b03a38
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 29 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: KramersMoyal CI

on: push
Expand All @@ -12,11 +9,11 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ['3.5', '3.6', '3.7', '3.8', '3.9', '3.10']
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019-2020 Rydin
Copyright (c) 2019–2023 Leonardo Rydin Gorjão

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
26 changes: 9 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pip install kramersmoyal
```
Then on your favourite editor just use
```python
from kramersmoyal import km, kernels
from kramersmoyal import km
```

## Dependencies
Expand Down Expand Up @@ -55,7 +55,7 @@ time = np.arange(0, t_final, delta_t)
y = np.zeros(time.size)

# Generate a Wiener process
dw = np.random.normal(loc = 0, scale = np.sqrt(delta_t), size = time.size)
dw = np.random.normal(loc=0, scale=np.sqrt(delta_t), size=time.size)

# Integrate the process
for i in range(1,time.size):
Expand All @@ -69,17 +69,9 @@ From here we have a plain example of an Ornstein–Uhlenbeck process, always dri
## Using `kramersmoyal`
Take the timeseries `y` and let's study the Kramers–Moyal coefficients. For this let's look at the drift and diffusion coefficients of the process, i.e., the first and second Kramers–Moyal coefficients, with an `epanechnikov` kernel
```python
# Choose number of points of you target space
bins = np.array([5000])

# Choose powers to calculate
powers = np.array([[1], [2]])

# Choose your desired bandwith
bw = 0.15

# The kmc holds the results, where edges holds the binning space
kmc, edges = km(y, bw=bw, bins=bins, powers=powers)
kmc, edges = km(y, powers=2)
```

This results in
Expand Down Expand Up @@ -130,7 +122,7 @@ Integrating the previous stochastic trajectory with a simple Euler–Maruyama in
y = np.zeros([time.size, 2])

# Generate two Wiener processes with a scale of np.sqrt(delta_t)
dW = np.random.normal(loc = 0, scale = np.sqrt(delta_t), size = [time.size, 2])
dW = np.random.normal(loc=0, scale=np.sqrt(delta_t), size=[time.size, 2])

# Integrate the process (takes about 20 secs)
for i in range(1, time.size):
Expand All @@ -147,7 +139,7 @@ First notice that all the results now will be two-dimensional surfaces, so we wi

```python
# Choose the size of your target space in two dimensions
bins = np.array([300, 300])
bins = [100, 100]

# Introduce the desired orders to calculate, but in 2 dimensions
powers = np.array([[0,0], [1,0], [0,1], [1,1], [2,0], [0,2], [2,2]])
Expand All @@ -160,7 +152,7 @@ powers = np.array([[0,0], [1,0], [0,1], [1,1], [2,0], [0,2], [2,2]])
bw = 0.1

# Calculate the Kramers−Moyal coefficients
kmc, edges = km(y, bw = bw, bins = bins, powers = powers)
kmc, edges = km(y, bw=bw, bins=bins, powers=powers)

# The K−M coefficients are stacked along the first dim of the
# kmc array, so kmc[1,...] is the first K−M coefficient, kmc[2,...]
Expand All @@ -182,11 +174,11 @@ Next on the list is
- Work through the documentation carefully

# Changelog
- Version 0.4.1 - Changing CI. Correcting `kmc[0,:]` normalisation.
- Version 0.4.1 - Changing CI. Correcting `kmc[0,:]` normalisation. Various Simplifications. Bins as ints, powers as ints.
- Version 0.4.0 - Added the documentation, first testers, and the Conduct of Fairness
- Version 0.3.2 - Adding 2 kernels: `triagular` and `quartic` and extending the documentation and examples.
- Version 0.31 - Corrections to the fft triming after convolution.
- Version 0.30 - The major breakthrough: Calculates the Kramers–Moyal coefficients for data of any dimension.
- Version 0.3.1 - Corrections to the fft triming after convolution.
- Version 0.3.0 - The major breakthrough: Calculates the Kramers–Moyal coefficients for data of any dimension.
- Version 0.2.0 - Introducing convolutions and `gaussian` and `uniform` kernels. Major speed up in the calculations.
- Version 0.1.0 - One and two dimensional Kramers–Moyal coefficients with an `epanechnikov` kernel.

Expand Down
2 changes: 1 addition & 1 deletion docs/source/license.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ License

MIT License

Copyright (c) 2019-2020 Rydin
Copyright (c) 2019–2023 Leonardo Rydin Gorjão

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
7 changes: 5 additions & 2 deletions kramersmoyal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from .kernels import epanechnikov, gaussian, uniform, silvermans_rule
from .kernels import epanechnikov, silvermans_rule
from .kmc import km

name = "kramersmoyal"
__name__ = 'kramersmoyal'
__version__ = '0.4.1'
__author__ = 'Leonardo Rydin Gorjão and Francisco Meirinhos'
__copyright__ = 'Copyright 2019–2023 Leonardo Rydin Gorjão, MIT License'
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
setuptools.setup(
name="kramersmoyal",
version="0.4.1",
author="Leonardo Rydin Gorjao and Francisco Meirinhos",
author="Leonardo Rydin Gorjão and Francisco Meirinhos",
author_email="[email protected]",
description="Calculate Kramers-Moyal coefficients for stochastic process of any dimension, up to any order.",
long_description=long_description,
Expand All @@ -18,5 +18,5 @@
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires='>=3',
python_requires='>=3.7',
)

0 comments on commit 0b03a38

Please sign in to comment.