Spooky Sale: 10% off Premium yearly · $118.80 for the first year · until Nov 6Get it

Deep-ML
Learn
Problems1,200+ hands-on ML problemsLearning PathA guided route through the fundamentalsLabsInteractive labs on real techniquesProjectsBuild a GPT, an RL agent, CUDA kernelsCollectionsCurated problem sets and videosMathPen-and-paper math for MLIntuitionInvent the idea behind the formula yourselfPlaylistsYour own problem lists, shareableStudy AssistantAn AI teacher that knows your progress
Interview Prep
Compete
ContestsFresh problem sets, ranked liveLeaderboardWhere you stand, globallyBuddiesSolve with a friend: streaks, a weekly board, chat
Discuss
Deep-Path
Premium
      Intuition
      56 of 102

      Shrink toward zero

      Fit a line through 0, y = slope * x, as in “Through the cloud”, but from only a few noisy points. Write careful_slope(xs, ys, caution): a slope that doesn’t trust thin evidence. caution ≥ 0 says how much you distrust a slope built on little evidence; 0 means no caution at all.

      Two points near 0 fit a line exactly, but measure them again with a little noise and the line swings wildly; two far-out points with the same noise barely move. The plain best slope trusts thin evidence too much. Your function builds in doubt, as much as the caution says.

      A line through 0 from only two points.two points near 0x 1 and 2plain slope: [2]two far pointsx 10 and 20plain slope: [2]careful_slope near points, caution 1: y = ? × x?
      Your functioncareful_slope(xs, ys, caution)
      xsthe points, point i is (xs[i], ys[i])e.g. [1, 2, 3]
      ysthe points, point i is (xs[i], ys[i])e.g. [2, 5, 5]
      cautioncaution >= 0: how much to distrust a slope built on little evidencee.g. 0
      returnsthe slope of the line y = slope * x
      solution.pyLoading Python
      Sign in for an AI hint
      ← Through the cloudSmooth the noise →