The interview problem

Practice prompt

You have a few expensive, noisy simulator runs and want predictions with uncertainty. At inputs 0 and 2, the standardized responses are 1 and 2. Use a zero-mean Gaussian process with kernel k(x, x′) = 2−|x−x′| and independent Gaussian observation-noise variance 1/4. Predict at input 1. Explain the difference between uncertainty about the function and about a new observation, and how you would implement and validate the model.

Original fundamentals practice, not a reported interview. Numerical scenario and calculations are original. Technical references retrieved September 27, 2026; interview date not applicable.

1. Define the random quantities

A Gaussian process specifies jointly Gaussian function values at any finite set of inputs. The mean function expresses a prior trend; the kernel specifies covariance. A valid kernel must produce positive-semidefinite covariance matrices, so an arbitrary similarity score is not sufficient.

Write y = f(X) + ε, with independent noise ε having variance σ². Here the signal variance is one and σ² = 1/4. Inputs and outputs are already in the stated standardized coordinates. Negative predictions are therefore permissible; this is not a model directly constrained to positive physical measurements.

Keep the kernel and noise parameters fixed for the worked calculation. Fitting those parameters and then treating their estimates as certain is a different uncertainty approximation from integrating over their posterior.

2. Condition the joint Gaussian

Let K be the training kernel matrix, k* the covariances between training inputs and the test input, and k** its prior variance. Set A = K + σ²I. For the zero-mean model, Gaussian conditioning gives:

posterior mean μ* = k*ᵀ A⁻¹ y
latent variance v* = k** − k*ᵀ A⁻¹ k*
new-observation variance = v* + σ²

The added σ² belongs to a new independent measurement. It is not added when predicting the latent function itself. With a nonzero fixed mean function, replace y by y − m(X) and add m(x*) to the prediction.

The conditioning equations are standard GP regression results; the following matrix example is original. A library's returned standard deviation depends on how noise is represented, so verify whether it describes the latent process or a noisy observation rather than adding noise twice.

3. Calculate the posterior by hand

The two training inputs are distance two apart, while the test point is distance one from each:

K = [[1, 1/4],       A = [[5/4, 1/4],
     [1/4, 1]]           [1/4, 5/4]]
k* = [1/2, 1/2]ᵀ       k** = 1
det(A) = 3/2
A⁻¹ = [[5/6, −1/6],
       [−1/6, 5/6]]

Multiplying by the observed response vector gives:

A⁻¹ [1, 2]ᵀ = [1/2, 3/2]ᵀ
μ* = (1/2)(1/2) + (1/2)(3/2) = 1
A⁻¹ k* = [1/3, 1/3]ᵀ
v* = 1 − [(1/2)(1/3) + (1/2)(1/3)] = 2/3
Var(y* | data) = 2/3 + 1/4 = 11/12

The mean is one rather than the naive average 1.5. The zero-mean prior and imperfect correlation with the training points shrink the prediction. A GP is not simply a distance-weighted average with weights constrained to sum to one.

Prediction targetMeanVarianceStandard deviationApproximate 95% interval
Latent f(1)12/30.8165[−0.6003, 2.6003]
New noisy y at 1111/120.9574[−0.8766, 2.8766]

The intervals use mean ± 1.96 standard deviations under the specified conditional Gaussian model. They are not distribution-free coverage guarantees and do not include uncertainty about a wrongly chosen kernel or noise model.

4. Check limiting cases before trusting the result

Far from both training inputs, this kernel's cross-covariances approach zero. The posterior mean returns to zero, the latent variance approaches one, and the observation variance approaches 1.25. The model does not extrapolate an arbitrary linear trend.

A bounded prior variance is not proof of safety outside the training domain. A wrong prior can be confidently wrong. Inspect predictions in the input regimes where the simulator will actually be queried.

With fixed hyperparameters, posterior covariance depends on input locations and noise, not the observed response values. Changing responses can change uncertainty indirectly when the hyperparameters are refitted. These are different statements.

In a separate dataset containing only n repeated independent measurements at one input, with unit prior variance and noise variance 1/4, the posterior latent variance at that input is 1/(1 + 4n). Four repeats give 1/17, while a new measurement still has an additional 1/4 noise variance. Correlated measurement errors would invalidate this independent-repeat calculation.

In the noiseless limit, distinct training points can be interpolated when the kernel matrix is nonsingular. Duplicate inputs or an invalid kernel can instead make the system singular; removing noise is not a universal numerical improvement.

5. Solve systems rather than forming an inverse

The inverse above makes a two-by-two example transparent. In production, use a Cholesky factorization and triangular solves:

A = LLᵀ
solve Lz = y
solve Lᵀα = z
mean = k*ᵀα
solve Lw = k*
latent variance = k** − wᵀw

A small diagonal jitter can address numerical conditioning, but it is distinct from the physical observation-noise model. Log it and test sensitivity. Large jitter used to hide an invalid covariance changes the result rather than fixing the model.

Tiny negative variances from floating-point roundoff may be handled with a justified tolerance. Substantial negative values require investigation of the kernel, solves or conditioning; blindly clipping everything to zero conceals errors.

Fit normalization on training data only and apply the same transform at prediction. Keep input units consistent with the kernel length scale. If output standardization is inverted, multiply variances by the square of the output scale, not the scale itself.

6. Budget dense inference

A conventional dense GP requires quadratic matrix storage and cubic factorization work. At 50,000 observations, one float64 matrix alone occupies:

50,000² × 8 bytes = 20,000,000,000 bytes = 20 GB

The factor, temporary arrays and training data add memory. At 10,000 observations the same matrix calculation gives 0.8 GB. These are decimal payload estimates, not total process memory.

After computing α, a single predictive mean needs a kernel vector and a linear-length dot product. Computing its variance with a dense triangular solve remains quadratic in the training-set size. Producing many variances can therefore be expensive even when means seem fast.

For larger datasets, compare inducing-point approximations, structured kernels or another regression model. Evaluate approximation quality in the intended input regions, not just runtime. An approximation that distorts uncertainty can undermine the reason for choosing a GP.

7. Validate the uncertainty as well as the mean

Compare prediction errors, predictive log scores and interval coverage on held-out observations. Use noisy-observation intervals when evaluating noisy labels. Break results down by distance from training data and relevant operating regimes.

Select kernel and noise settings without leaking evaluation outcomes into the final assessment. Marginal-likelihood optimization is useful model fitting, but it does not establish that the chosen family captures the simulator. A very long length scale can miss abrupt changes; a very short one can overreact to noise.

Consider whether noise varies by input or whether repeated runs share disturbances. Outliers and non-Gaussian errors can invalidate the simple Gaussian likelihood. Compare alternative assumptions and collect additional runs where the decision is sensitive.

A narrow interval under fixed parameters should be reported as conditional on those choices. Calibration evidence from one region or time period does not automatically extend to a new simulator version or operating range.

Failure analysis and self-review

  • Observation intervals are too narrow: check whether measurement noise was omitted.
  • Noise is counted twice: inspect the library's kernel and prediction semantics.
  • Far-away predictions look certain: examine prior reversion and model misspecification.
  • The covariance cannot be factorized: investigate duplicates, kernel validity and conditioning.
  • Validation uses future normalization: refit preprocessing inside the training split.
  • Fast mean prediction hides slow variance prediction: budget both computations.

Follow-ups: What changes with a nonzero prior mean? Why does fixed-parameter covariance not depend on y? How do repeated measurements differ from nearby inputs? What happens if the observation noise is correlated? How would an inducing-point approximation affect your acceptance tests?

A strong answer derives the posterior and separates latent from observation variance. An excellent answer checks limiting cases, uses stable solves, budgets dense computation and explains the conditions behind uncertainty claims.

Sources and attribution

Retrieved September 27, 2026. The simulator prompt, two-point calculation and resource examples are original. No company interview attribution or claim about current best-model performance is made.

Continue your preparation

Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.