For each function, sample the value at `N` equally spaced points in the [−5, 5] interval (Fortuin and Rätsch, 2019). Returns: Tuple of np.arrays of size (N, 1) and (N, num_functions).
(num_functions=10, N=500)
| 46 | |
| 47 | # %% |
| 48 | def generate_data(num_functions=10, N=500): |
| 49 | """ |
| 50 | For each function, sample the value at `N` equally spaced |
| 51 | points in the [−5, 5] interval (Fortuin and Rätsch, 2019). |
| 52 | |
| 53 | Returns: |
| 54 | Tuple of np.arrays of size (N, 1) and (N, num_functions). |
| 55 | """ |
| 56 | jitter = 1e-6 |
| 57 | Xs = np.linspace(-5.0, 5.0, N)[:, None] |
| 58 | kernel = RBF(lengthscales=1.0) |
| 59 | cov = kernel(Xs) |
| 60 | L = np.linalg.cholesky(cov + np.eye(N) * jitter) |
| 61 | epsilon = np.random.randn(N, num_functions) |
| 62 | F = np.sin(Xs) + np.matmul(L, epsilon) |
| 63 | return Xs, F |
| 64 | |
| 65 | |
| 66 | # %% [markdown] |
no test coverage detected
searching dependent graphs…