MCPcopy Create free account
hub / github.com/amazon-science/chronos-forecasting / random_binary_map

Function random_binary_map

scripts/kernel-synth.py:62–79  ·  view source on GitHub ↗

Applies a random binary operator (+ or *) with equal probability on kernels ``a`` and ``b``. Parameters ---------- a A GP kernel. b A GP kernel. Returns ------- The composite kernel `a + b` or `a * b`.

(a: Kernel, b: Kernel)

Source from the content-addressed store, hash-verified

60
61
62def random_binary_map(a: Kernel, b: Kernel):
63 """
64 Applies a random binary operator (+ or *) with equal probability
65 on kernels ``a`` and ``b``.
66
67 Parameters
68 ----------
69 a
70 A GP kernel.
71 b
72 A GP kernel.
73
74 Returns
75 -------
76 The composite kernel `a + b` or `a * b`.
77 """
78 binary_maps = [lambda x, y: x + y, lambda x, y: x * y]
79 return np.random.choice(binary_maps)(a, b)
80
81
82def sample_from_gp_prior(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…