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
      6 of 88

      Average on the go

      Values arrive one at a time (sensor readings, rewards, losses) and you can’t keep them all. Write update(average, count, new_value): the new average after one more value arrives, from the old average and count, how many values that average was over. At the start nothing has arrived: average and count are both 0.

      values, arriving one at a time
      1st2nd3rd4th
      2491
      the average so far
      1st2nd3rd4th
      2354
      solution.pyLoading Python
      ← Average speedAs the crow flies →