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
      95 of 102

      Ask the wrong crowd

      A new café wants to know how its town rates it (1 to 10), but the survey was done wherever people were easy to reach, so the crowd you asked isn’t the crowd you want. Write estimate(ratings, asked_chances, wanted_chances): your best guess of the average rating in the crowd you want. For each answer you got: its rating, how common that kind of person (student, worker, retiree) is in the crowd you asked, and how common in the crowd you want.

      You want to know what the whole town thinks of a new café, but the only people you can ask are the ones sitting in it, and they’re nearly all students. Click anyone to see who they are and what they said.

      You can only ask the people in the café.who you asked: the caféstudentretireehow they rate the café, 0 to 10012345678910the café says 2.6the town really thinks 5off by 2.4estimate(the town, from the café’s answers alone) →?
      Your functionestimate(ratings, asked_chances, wanted_chances)
      ratingsratings[i]: what the i-th person you asked said (1 to 10)e.g. [4, 2, 5, 3]
      asked_chancesasked_chances[i]: how common their kind is in the crowd you askede.g. [0.2, 0.5, 0.3, 0.5]
      wanted_chanceswanted_chances[i]: how common their kind is in the crowd you wante.g. [0.2, 0.5, 0.3, 0.5]
      returnsthe average rating you'd expect in the crowd you want
      solution.pyLoading Python
      Sign in for an AI hint
      ← Try the unknownWhich answer do people prefer? →