## Exact random sums

Sometimes, you need a list of random numbers that sum to a known constant. There's a known algorithm to provide this list of numbers with the proper distribution, but a straight-forward implementation may give a list that doesn't sum exactly to the desired constant because of rounding error.

This article describes the basic algorithm, why the rounding error happens, and the solution.

## Precision of random numbers

In some sense, random numbers uniformly-distributed in the range $$[0, 1)$$ are the easiest class of random number to generate.

Because of the internal representation of floating-point numbers, all you need to do is fill the significand with random bits, set the exponent to -1, and the sign bit to positive.

Some language run-times do this better than others.

Continue reading "Precision of random numbers"

## certbot and tinydns

Let's Encrypt now supports wildcard certificates. To confirm DNS control, they support several different DNS providers and dynamic DNS protocols, but they don't yet have a plugin for tinydns by DJ Bernstein.

Luckily, the excellent designs of both certbot and tinydns make it very easy to support on your own.

## von Neumann's 4-player {1/3, 1/3, -1/3, -1/3} imputation

In Theory of Games and Economic Behavior, von Neumann discusses solutions to some kinds of zero-sum four-person games. See section 37.4.2, page 317. There, he finds that one set of imputations is incomplete, and must have at least another imputation added to it. He writes that [it] seems very difficult to find a heuristic motivation for the steps which are now necessary before giving the imputation as:

$$\vec a^{IV} = \left\{1/3, 1/3, -1/3, -1/3\right\}$$

The situation is unusual in that the first three players have formed a coalition against the fourth. So, why does the third player have the same loss as the fourth? This is the heuristic that von Neumann didn’t provide, and he concludes by saying only that [if] a common-sense interpretation of this solution… is wanted, … it seems to be some kind of compromise between a part (two members) of a possible victorious coalition and the other two players.

However, there’s an intriguing possibility.

Continue reading "von Neumann's 4-player {1/3, 1/3, -1/3, -1/3} imputation"

## Exponential Moving Average (EMA) Rates, part 3

In the last post, we created an online implementation of an EMA to measure the rate of a Poisson event. However, it has the “warm-up” period seen in most EMA implementations.

This time, we’ll correct that. The technique is similar to what I wrote in The correct way to start an Exponential Moving Average (EMA).

Continue reading "Exponential Moving Average (EMA) Rates, part 3"