P
Piotr Kobzda
Eric said:Piotr said:[...]
Anyway, how about reimplementing it as follows:
private static final long maxr = 1L << 53;
private long lastr = nextr();
private long nextr() {
return ((long)next(26) << 27) + next(27) + next(1);
}
This returns 42 twice as often as it returns 0 or maxr.
The mean of the distribution is correct, but the variance is
a wee bit too small: there is too much "central tendency."
That's the property of nextr(). But the "central tendency" is
propagated later into other values through shifting it from lastr. So,
where is no "center".
Is there any point in pursuing this further?
On, if you are satisfied with the results achieved. And maybe it's my
fault, but I'm not.
We've known
since the beginning that there's no practical need for a [0,1]
as opposed to [0,1) distribution, and even if someone wants to
use it for "impractical" reasons a correct solution has already
been posted.
Correct solutions posted already are less efficient than the latest one.
The rest is just intellectual niggling about how
many angels can dance on the least-significant bit, and has
ceased to have much to do with Java programming.
True. But a lot of interesting problems covered by Java are not
strictly Java related, aren't they?
If the question
still interests you as a theoretical study -- there's no harm
and much good in pursuing such interests -- perhaps it would be
better explored in comp.programming, say, or maybe sci.math.
Maybe, but 1) I'm to lazy to start a new discussion (yes, I know, it's a
shame); 2) I know that here are also the people who knows some aspects
of the domains shared by the newsgroups mentioned by you (evidence is
even in this thread!).
Of course, if a luck of the satisfactory answers will cause me waking up
at the middle of the night with a sweat on my brow, I'll consider to
continue it somewhere else. Thanks!
piotr