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)
| 60 | |
| 61 | |
| 62 | def 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 | |
| 82 | def sample_from_gp_prior( |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…