Random Fourier features approximate the RBF kernel by an inner product of explicit features, turning a kernel method into a linear one.
Implement rff_features(X, M, sigma, seed, orthogonal=False) with ( even), returning of shape (N, M) (all sines first, then all cosines). Draw with rng = np.random.default_rng(seed):
orthogonal=False: rng.standard_normal((T, D)) / sigma.orthogonal=True (orthogonal random features): for each block in turn, draw G = rng.standard_normal((D, D)), take Q, _ = np.linalg.qr(G), draw S = np.linalg.norm(rng.standard_normal((D, D)), axis=1) and form the block S[:, None] * Q; stack the blocks row-wise, keep the first rows, and divide by sigma.Then implement Bayesian linear regression on the features, rff_bayes_linreg(Phi, y, Phi_star, sigma_w, sigma_y), with prior and likelihood . Return (mean, var): the posterior predictive mean of and its variance (without the observation noise).