PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Statistics & Math/Google

Generate Uniform Samples and Estimate Percentiles

Last updated: Apr 2, 2026

Quick Overview

This question evaluates understanding of random sampling and transformation of uniform variables alongside histogram-based percentile estimation and interpolation for quantile approximation.

  • medium
  • Google
  • Statistics & Math
  • Data Scientist

Generate Uniform Samples and Estimate Percentiles

Company: Google

Role: Data Scientist

Category: Statistics & Math

Difficulty: medium

Interview Round: Technical Screen

Answer the following two probability/statistics questions. 1. You are given access to a function `rand01()` that returns independent samples from `Uniform(0, 1)`. Write a function `sample_square()` that returns a 2D point `(x, y)` uniformly distributed over the square `(-1, 1) x (-1, 1)`. 2. You are given an aggregated histogram for a numeric variable related to search queries. Each bucket `i` contains: - `left_bd` (float): left boundary of the bucket - `right_bd` (float): right boundary of the bucket - `search_count` (int): number of observations in that bucket There are `K` ordered, non-overlapping buckets, and you do not have access to the raw observations. Describe how to estimate the `p`-th percentile, where `p` is between `0` and `100`. First discuss a naive approach based on the bucket that contains the percentile, then propose a better approximation that uses interpolation within that bucket. State any assumptions your method relies on.

Quick Answer: This question evaluates understanding of random sampling and transformation of uniform variables alongside histogram-based percentile estimation and interpolation for quantile approximation.

Related Interview Questions

  • Measure Bird Species Segregation - Google (medium)
  • Estimate weather’s effect on mental health - Google (easy)
  • Explain Bootstrap and Statistical Inference - Google (hard)
  • Explain Bootstrap and Prove Uniformity - Google (hard)
  • Can bootstrap help reduce variance - Google (medium)
Google logo
Google
Mar 27, 2025, 12:00 AM
Data Scientist
Technical Screen
Statistics & Math
4
0
Loading...

Answer the following two probability/statistics questions.

  1. You are given access to a function rand01() that returns independent samples from Uniform(0, 1) . Write a function sample_square() that returns a 2D point (x, y) uniformly distributed over the square (-1, 1) x (-1, 1) .
  2. You are given an aggregated histogram for a numeric variable related to search queries. Each bucket i contains:
  • left_bd (float): left boundary of the bucket
  • right_bd (float): right boundary of the bucket
  • search_count (int): number of observations in that bucket

There are K ordered, non-overlapping buckets, and you do not have access to the raw observations. Describe how to estimate the p-th percentile, where p is between 0 and 100. First discuss a naive approach based on the bucket that contains the percentile, then propose a better approximation that uses interpolation within that bucket. State any assumptions your method relies on.

Solution

Show

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Statistics & Math•More Google•More Data Scientist•Google Data Scientist•Google Statistics & Math•Data Scientist Statistics & Math
PracHub

Master your tech interviews with 8,000+ 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.