InterviewStack.io LogoInterviewStack.io

Linear Algebra and Numerical Computing Questions

Applied mathematics for computation: matrix and vector operations, linear-algebra foundations, numerical stability, optimization, and the mathematical/statistical rigor behind machine-learning theory. Covers formulating problems mathematically and reasoning about precision and convergence. Serves quantitative and research-leaning engineering roles.

HardTechnical
68 practiced

You observe numerical instability when summing many small floating-point numbers per group (loss of precision). Describe algorithms or approaches to improve numerical stability in Python/NumPy/pandas: pairwise summation, Kahan summation, using higher precision, or compensated algorithms. Show how to implement a numerically stable group-sum in numpy/pandas.

EasyTechnical
81 practiced

Explain NumPy broadcasting rules with a concrete example: add a (3,1) array to a (3,4) array. Show a short code snippet demonstrating broadcasting vs an equivalent Python loop, and explain why broadcasting leads to better performance for ML preprocessing tasks.

MediumTechnical
100 practiced

Implement a function mad_outlier_mask(x: np.ndarray, thresh: float = 3.5) -> np.ndarray that returns a boolean mask marking outliers based on the Median Absolute Deviation (MAD). Use vectorized NumPy operations (no Python loops), handle NaNs by ignoring them in medians, and return a mask of the same shape as x.

EasyTechnical
83 practiced

Given two NumPy arrays a (shape (n,)) and b (shape (m,)), write Python/NumPy code to compute the matrix of squared Euclidean distances between each pair of elements (result shape (n, m)) using broadcasting without explicit Python loops. Comment on the memory cost of your approach and one technique to reduce memory if needed.

That is every published Linear Algebra and Numerical Computing question for Machine Learning Engineer so far. Browse the other topics in this category, or practice this one interactively.