Basis Lab

Answering With Random Samples

Making a Random Draw

Last timeWhen the Formula Runs Out

Everything starts from numbers drawn evenly between zero and one. Two standard moves turn those into draws from whatever distribution the problem actually has.

The previous lesson assumed draws of the right kind were available. This one

makes them.

Everything begins with one stream: numbers spread evenly between zero and one,

with no detectable relationship between successive values. Every other draw in

every simulation is manufactured from that stream.

FIG 1An even draw, turned into a waiting time
one number drawn evenly between zero and one, the raw material
the cumulative function: the chance that the waiting time is at most t
the rate, so events arrive \lambda times per unit of time on average
the resulting draw, which has the wanted waiting time distribution exactly
the natural logarithm, which appears because the cumulative is built from e
The last expression is the cumulative solved for t, which is all the method is. Read it as a picture rather than algebra: the even draw picks a height between zero and one on the cumulative curve, and the inverse reads off the value sitting at that height. Where the curve rises steeply, a wide band of heights maps into a narrow band of values, so that region collects more draws, which is exactly what a high density means. The method is exact rather than approximate, it costs one logarithm per draw, and it works for any distribution whose cumulative can be inverted.
FIG 2The cumulative curve the method reads backwards
0.000.300.600.901.200.01.32.53.85.0waiting time
cumulative, rate onecumulative, rate two
An even draw is a height on the vertical axis, and the draw produced is the time directly below where that height meets the curve. Both curves rise steeply near zero and flatten out, so most heights land in the early region and short waits are common, while the long tail still receives the occasional draw from a height close to one. Doubling the rate steepens the curve, which pulls the same set of heights into shorter times, and that is the whole effect of the rate parameter. Reading the picture this way makes the method obvious and removes any need to remember the formula.

When the inverse is unavailable

Most distributions have no cumulative that can be inverted in closed form,

including the normal one. The fallback is to propose and reject.

The lesson stops here

1 more paragraph to go

You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.

The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.

See the planThe contents

This is the reading half

Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.

The contents

The rest of this course

  1. 01When the Formula Runs Out
  2. 02Making a Random Drawyou are here
  3. 03The Average Is the Answeropening only
  4. 04How Far Off Is Itopening only
  5. 05Making Each Sample Countopening only
  6. 06Running the Whole Processopening only
  7. 07Using the Data You Have Twiceopening only
  8. 08When a Simulation Liesopening only

Read alongside