PracHub
QuestionsCoachesLearningGuidesInterview Prep
|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)
  • Leverage Existing Model for Low Credit Score Applicants - Upstart (medium)
  • Design Push-Notification System for Airport Surge Pricing - Upstart (medium)
  • How to Architect a Personalized Ads Serving System - Upstart (hard)
|Home/Machine Learning/Upstart

Implement PAVA spend-smoothing under no-borrowing constraint

Upstart logo
Upstart
Oct 13, 2025, 9:49 PM
hardData ScientistTechnical ScreenMachine Learning
10
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.
Loading comments...

Browse More Questions

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

Write your answer

Your first approved answer each day earns 20 XP.

Sign in to write your answer.
PracHub

Master your tech interviews with 8,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
  • AI Coding 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.