master-thesis/python/graveyard/billohops/test_stochproc.org

70 lines
1.6 KiB
Org Mode
Raw Normal View History

2021-10-11 10:27:11 +02:00
#+PROPERTY: header-args :session stochproc_hartmann :kernel python :pandoc t
#+begin_src jupyter-python
%load_ext autoreload
%autoreload 2
import numpy as np
import stocproc as s
import matplotlib.pyplot as plt
#+end_src
#+RESULTS:
#+begin_src jupyter-python
class Kernels:
@classmethod
def constant(_, c):
def kernel(t):
shp = np.max(t.shape)
return np.ones((shp, shp)) * c
return kernel
@classmethod
def squared_exp(_, l):
def kernel(t):
return np.exp(-t ** 2 / l)
return kernel
@classmethod
def periodic(_, a, ω):
def kernel(t):
return np.exp(-np.abs(np.sin((t)) * ω) * a)
return kernel
@classmethod
def squares(_):
def kernel(t):
return t ** 2
return kernel
#+end_src
#+RESULTS:
#+begin_src jupyter-python
proc = s.StocProc_KLE(Kernels.squared_exp(10), 10)
#+end_src
#+RESULTS:
: stocproc.method_kle - INFO - check 33 grid points
2021-10-22 18:00:30 +02:00
: stocproc.method_kle - INFO - calc_ac 3.027%, fredholm 4.107%, integr_intp 1.991%, spline 8.315%, calc_diff 54.892%, rest 27.668%
2021-10-11 10:27:11 +02:00
: stocproc.method_kle - INFO - auto ng SUCCESSFUL max diff 8.097e-03 < tol 1.000e-02 ng 33 num evec 6
: alpha_k is real
#+begin_src jupyter-python
proc.new_process()
plt.plot(proc.t, np.imag(proc()))
plt.plot(proc.t, np.real(proc()))
#+end_src
#+RESULTS:
:RESULTS:
2021-10-22 18:00:30 +02:00
| <matplotlib.lines.Line2D | at | 0x7f79997659d0> |
[[file:./.ob-jupyter/54e5aff8211858e4fdf46d25daacce53d67b2f50.png]]
2021-10-11 10:27:11 +02:00
:END: