Week 71 of 145 · TAOCP Vol 2: Seminumerical Algorithms

TAOCP 3.4.1 Numerical Distributions

2 tasks, 5 steps. Open a task's steps to see exactly what to do; each guide has the detail.

Sign up or sign in to tick these off and give this week a due date.

By the end of this week you can

  • Implement an unbiased random integer in a range without modulo bias.
  • Explain how the alias method samples a discrete distribution in constant time.
  • Use inversion to turn uniform deviates into exponential deviates.

Week 71 · Self-check

Three quick questions

Ungraded, and it never holds anything up. Pick an answer to see why.

  1. A generator gives integers 0 to 7 uniformly, and you use X mod 3. What is the probability of getting 0?
  2. Given a uniform deviate U in (0, 1), which gives an exponential deviate with mean μ?
  3. You need millions of samples from a fixed weighted die with 1000 faces, in constant time each. Which approach fits?

Nothing is saved while signed out.

Discussion

0 posts

Stuck on week 71, or finished early? Say what you tried and what happened. Hints over answers: full solutions go in a spoiler.

No posts yet. Ask a question or share a tip.

Sign in to postAnyone can read. Posting needs an account with a confirmed email.

Spot a mistake? Report it