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

1.6 KiB

  %load_ext autoreload
  %autoreload 2
  import numpy as np
  import stocproc as s
  import matplotlib.pyplot as plt
  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
  proc = s.StocProc_KLE(Kernels.squared_exp(10), 10)
stocproc.method_kle - INFO - check 33 grid points
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%
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
  proc.new_process()
  plt.plot(proc.t, np.imag(proc()))
  plt.plot(proc.t, np.real(proc()))
<matplotlib.lines.Line2D at 0x7f79997659d0>

/hiro/master-thesis/media/commit/4f8c7e75eaf1b2b85615979aaac0ef3ad683fa0d/python/graveyard/billohops/.ob-jupyter/54e5aff8211858e4fdf46d25daacce53d67b2f50.png