master-thesis/python/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 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
  proc.new_process()
  plt.plot(proc.t, np.imag(proc()))
  plt.plot(proc.t, np.real(proc()))
<matplotlib.lines.Line2D at 0x7f951f7236d0>

/hiro/master-thesis/media/commit/0c6a153f7c9d91095eef0018de734dda5d801ff6/python/billohops/.ob-jupyter/4ffe13e8d71bc05a2a7ec0d8dbdbec4e2c300f57.png