Imagine you wish to encode a non-negative integer across N buckets, where each bucket can hold a unary number. The probability of an integer being given as input to the encoder is specified by a function P(i) which sums to 1.
N = 1, you more or less have to encode the number in unary. So if you want to express 42, you will need to use 42 symbols, all in the first (and only) bucket.
N = 2, you start getting options. Example: you might say that the second bucket is the tens place. So expressing 42 could be done with 2 symbols in the first bucket, and 4 in the second, for a total of 6.
P is fixed, but you don't a-priori know what N is. What's desired is a system of encoding which for a given N will use (on average) as few unary "digits" as possible to encode a number from P.
I don't want to prescribe what kind of function P is--it could be uniform within a range (so long as it included 0), or gaussian or whatever. But having it specified seems necessary to make the problem one that has "a solution".
I'm curious if this maps to an existing problem, or if someone here would have an approach to addressing it...