Skip to content
nonconvexcard

Simulate distance contrast

CodingBeginner⏱ 30 minClassical MLsimulationcontrastdimensionknn

Problem

Simulate NN points in Rd\R^d and measure the contrast (max⁡i∥xi−q∥−min⁡i∥xi−q∥)/min⁡i∥xi−q∥(\max_i\|x_i-q\| - \min_i\|x_i-q\|)/\min_i\|x_i-q\| as dd grows.

  1. Confirm the contrast decays and identify the rate.
  2. Repeat with data lying on a d0d_0-dimensional subspace embedded in Rd\R^d and show the contrast is governed by d0d_0.
  3. Repeat with an anisotropic covariance with a power-law spectrum and comment.

Implement it, then check the implementation against something you can verify independently.

Write it

Solve it here7 tests · Python runs in your browser
⌘/Ctrl + ↵ to run · limit 60s · draft saved in this browser
7 tests will run against your code. The first run downloads the Python runtime — several megabytes, once per browser.

Solution

Opening this before you have a real attempt on paper is the fastest way to feel like you understand something you cannot reproduce.

Related problems

All problems
SolvedProblemFieldTypeDifficultyTime
Johnson–Lindenstrauss dimension arithmeticHigh-Dim ProbabilityNumericalBeginner15 min
Two different curses of dimensionalityClassical MLNumericalBeginner15 min
A sufficient condition for correct retrievalRAGProofIntermediate30 min
Balls into bins, with one choice and with two runAI SystemsCodingIntermediate1 hour
Cache hit rates under Zipf popularity runAI SystemsCodingIntermediate1 hour