PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Machine Learning/Upstart

Implement PAVA spend-smoothing under no-borrowing constraint

Last updated: Mar 29, 2026

Quick Overview

This question evaluates isotonic L2 regression, constrained quadratic optimization, and algorithmic implementation skills through a monotone spending plan with cumulative no-borrowing constraints, including designing and verifying an O(n) Pool-Adjacent-Violators-style routine and its empirical error/runtime.

  • hard
  • Upstart
  • Machine Learning
  • Data Scientist

Implement PAVA spend-smoothing under no-borrowing constraint

Company: Upstart

Role: Data Scientist

Category: Machine Learning

Difficulty: hard

Interview Round: Technical Screen

You are given a length-65 vector profit[1..65] of yearly discretionary income (can be treated as nonnegative real numbers). We want a spending plan s[1..65] that is as even as possible over time while not spending future money. Formally, solve: minimize Σ_{t=1..65} (s_t − profit_t)^2 subject to s_1 ≤ s_2 ≤ … ≤ s_65, s_t ≥ 0, and Σ_{i=1..t} s_i ≤ Σ_{i=1..t} profit_i for all t (no borrowing), with Σ_{t} s_t = Σ_{t} profit_t (no money left unallocated). 1) Show that the solution is the isotonic L2 regression of profit under a nondecreasing constraint (Pool-Adjacent-Violators Algorithm, PAVA) and explain why it respects no-borrowing when mass is only shifted forward. 2) Implement an O(n) PAVA (R or Python), returning s and the block structure. 3) Using set.seed(12345) and profit ~ rnorm(65, mean=1000, sd=100) (clip at 0 if needed), run your algorithm, report Σ(s_t − profit_t)^2, verify monotonicity, and demonstrate that cumulative spend never exceeds cumulative profit at any prefix. 4) Compare against a naive iterative averaging method (like repeatedly averaging decreasing runs) on both correctness and runtime.

Quick Answer: This question evaluates isotonic L2 regression, constrained quadratic optimization, and algorithmic implementation skills through a monotone spending plan with cumulative no-borrowing constraints, including designing and verifying an O(n) Pool-Adjacent-Violators-style routine and its empirical error/runtime.

Related Interview Questions

  • Explain L1 vs L2 and ridge vs lasso - Upstart (easy)
  • Derive logistic regression objective and gradients - Upstart (easy)
  • Address Missing Income Bracket in California Housing Data - Upstart (hard)
  • Design Push-Notification System for Airport Surge Pricing - Upstart (medium)
  • How to Architect a Personalized Ads Serving System - Upstart (hard)
Upstart logo
Upstart
Oct 13, 2025, 9:49 PM
Data Scientist
Technical Screen
Machine Learning
8
0

Monotone Spending Plan via Isotonic L2 Regression (No-Borrowing)

Context: You observe yearly discretionary income profit[1..65] (nonnegative reals) and want a spending plan s[1..65] that is as even (nondecreasing) as possible over time while never spending future money. Formally, solve the quadratic program:

  • Minimize: Σ_{t=1}^{65} (s_t − profit_t)^2
  • Subject to:
    1. 0 ≤ s_1 ≤ s_2 ≤ … ≤ s_65 (smoothly nondecreasing spending)
    2. For all t: Σ_{i=1}^t s_i ≤ Σ_{i=1}^t profit_i (no borrowing)
    3. Σ_{t=1}^{65} s_t = Σ_{t=1}^{65} profit_t (no unallocated money)

Tasks:

  1. Show that the solution is the isotonic L2 regression of profit under the nondecreasing constraint (solved by the Pool-Adjacent-Violators Algorithm, PAVA), and explain why it respects no-borrowing when mass is only shifted forward.
  2. Implement an O(n) PAVA (R or Python) that returns s and the block structure.
  3. Using set.seed(12345) and profit ~ rnorm(65, mean=1000, sd=100) (clip at 0 if needed), run your algorithm, report Σ(s_t − profit_t)^2, verify monotonicity, and demonstrate that cumulative spend never exceeds cumulative profit at any prefix.
  4. Compare against a naive iterative averaging method (e.g., repeatedly averaging decreasing runs) on both correctness and runtime.

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Machine Learning•More Upstart•More Data Scientist•Upstart Data Scientist•Upstart Machine Learning•Data Scientist Machine Learning
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.