- Notifications
You must be signed in to change notification settings - Fork0
Solving nonlinear stochastic differential equation
License
akononovicius/pyNSDE
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Here we have implemented solution of nonlinear SDE:
In this context "solution" is understood as obtaining single sampletrajectory of desired length and discretization time step.
The numerical solution is obtained by solving Bessel process SDE:
and applying nonlinear transformation:
to obtain the solutions of the nonlinear SDE above.
Bessel process is solved using Euler-Maruyama method with variable time step.
You could use this library to generate time series, which exhibit pink or1-over-f noise. Depending on the model and simulation parameters this can beachieved in an arbitrarily broad range of frequencies. Below follows examplewith simulation results of the calculation with mostly default parametervalues.
importnumpyasnpimportmatplotlib.pyplotaspltfrompyNSDEimportgenerate_seriesfromstats.pdfimportMakeLogPdffromstats.psdimportMakeSegLogPsd# simulationseries=generate_series(1048576,1e-3,seed=123)# calculating PDF / PSDpdf=MakeLogPdf(series)psd=MakeSegLogPsd(series,fs=1e3)# creating simple visualizationplt.figure(figsize=(12,3))plt.subplot(131)plt.xlabel('t')plt.ylabel('x(t)')plt.plot(series[::256],'r-')plt.subplot(132)plt.loglog()plt.xlabel('x')plt.ylabel('p(x)')plt.plot(pdf[:,0],pdf[:,1],'r-')plt.plot(pdf[:,0],2*(pdf[:,0]**-3),'k--')plt.subplot(133)plt.loglog()plt.xlabel('f')plt.ylabel('S(f)')plt.plot(psd[:,0],psd[:,1],'r-')plt.plot(psd[20:,0],1.5*(psd[20:,0]**-1),'k--')plt.tight_layout()plt.show()
In this code snippetstats
library was cloned fromhttps://github.com/akononovicius/python-stats.
Earlier implementation of a less flexible program solving the same nonlinearstochastic differential equation is available athttps://github.com/JuliusRuseckas/numerical-sde-variable-step.
https://github.com/akononovicius/python-stats library might be useful whenanalyzing simulated time series.
Couple of scientific review papers specific to the SDE being solved:
- B. Kaulakys and J. Ruseckas,Stochastic nonlinear differential equation generating 1/f noise, Phys. Rev. E70, 020101 (2004). doi:10.1103/PhysRevE.70.020101.arXiv:cond-mat/0408507 [cond-mat.stat-mech].
- B. Kaulakys, J. Ruseckas, V. Gontis and M. Alaburda,Nonlinear stochastic models of 1/f noise and power-law distributions, Physica A365, 217-221 (2006). doi:10.1016/j.physa.2006.01.017.arXiv:cond-mat/0509626 [cond-mat.stat-mech].
Recent review with variety of applications related to the SDE being solved:
- R. Kazakevičius, A. Kononovicius, B. Kaulakys, V. Gontis.Understanding the nature of the long-range memory phenomenon in socio-economic systems. Entropy23: 1125 (2021).doi: 10.3390/e23091125.arXiv:2108.02506 [physics.soc-ph].
About
Solving nonlinear stochastic differential equation