Google · ML Coding
Generate binomial matrix and column-normalize
TrueInterview
October 7, 2026 · 1 min read
Using Python with NumPy, generate a matrix of draws from a Binomial distribution with and , using a fixed random seed. Then normalize each column so that it sums to .
Requirements:
- The code must be vectorized.
- Guard against any column that is all zeros: either leave such a column as all zeros, or replace it with a uniform distribution. State which choice you made.
- Verify numerically that the column sums are within floating-point tolerance.
- Give the time and space complexity of your solution.
- Provide a brief unit test.
Hints (3)
Loading comments…