mirror of
https://github.com/vale981/master-thesis
synced 2025-03-09 04:36:39 -04:00
70 lines
1.6 KiB
Org Mode
70 lines
1.6 KiB
Org Mode
|
#+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
|
||
|
: stocproc.method_kle - INFO - calc_ac 1.275%, fredholm 2.881%, integr_intp 2.057%, spline 7.711%, calc_diff 59.392%, rest 26.684%
|
||
|
: 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:
|
||
|
| <matplotlib.lines.Line2D | at | 0x7f951f7236d0> |
|
||
|
[[file:./.ob-jupyter/4ffe13e8d71bc05a2a7ec0d8dbdbec4e2c300f57.png]]
|
||
|
:END:
|