 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>> $10,
>
> It's an even game for 20 throws, favours me for higher. You must show me
> that you have $524,288.
OOC why the 20 and why the $2^19 figues? That's what I was really
interested in.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
> Also, I assume that you're familiar with the name of this puzzle, but on
> the off chance that you're not:
> http://en.wikipedia.org/wiki/St._Petersburg_paradox
No I wasn't aware of the name (so as usual it is then very hard to find any
info about it), thanks!
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
scott <sco### [at] scott com> wrote:
> (rand()%2) == 0
> to
> rand() <= RAND_MAX/2
The rand() function in most compilers is of extremely poor quality and
should never be used for this type of application. You should always use
a very high-quality RNG with a humongous period.
I used (my C++ version of) the ISAAC RNG, which should be of fairly high
quality.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> The rand() function in most compilers is of extremely poor quality and
> should never be used for this type of application. You should always use
> a very high-quality RNG with a humongous period.
>
> I used (my C++ version of) the ISAAC RNG, which should be of fairly high
> quality.
I understand the Mersenne Twister is designed specifically for these
kinds of simulations - but I don't know how widely available it is...
PS. One time I wrote my own PRNG just to generate some random data for
testing purposes. I don't know why I didn't use the PRNG library, but I
should have; on investigation, it turns out that my own PRNG almost
always has a period of 2. (!!) Oops...
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Invisible <voi### [at] dev null> wrote:
> I understand the Mersenne Twister is designed specifically for these
> kinds of simulations - but I don't know how widely available it is...
The ISAAC RNG is faster than MT. I don't know about quality, but it should
be very competitive at least.
> PS. One time I wrote my own PRNG just to generate some random data for
> testing purposes. I don't know why I didn't use the PRNG library, but I
> should have; on investigation, it turns out that my own PRNG almost
> always has a period of 2. (!!) Oops...
One of the basic things taught at school is that you should never attempt
to make your own PRNG if you don't have extensive experience about the
subject, if you want any kind of quality to it.
Another thing with the exact same rule is a hashing function.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>> I understand the Mersenne Twister is designed specifically for these
>> kinds of simulations - but I don't know how widely available it is...
>
> The ISAAC RNG is faster than MT. I don't know about quality, but it should
> be very competitive at least.
Well I seriously doubt it can possibly be any *worse* than an LCG.
(Otherwise... why would they have designed it?)
>> PS. One time I wrote my own PRNG just to generate some random data for
>> testing purposes. I don't know why I didn't use the PRNG library, but I
>> should have; on investigation, it turns out that my own PRNG almost
>> always has a period of 2. (!!) Oops...
>
> One of the basic things taught at school is that you should never attempt
> to make your own PRNG if you don't have extensive experience about the
> subject, if you want any kind of quality to it.
>
> Another thing with the exact same rule is a hashing function.
Or, indeed, several other kinds of construct. (E.g., it's notoriously
hard to make a good encryption algorithm.)
In my defense, in the incident in question "good quality" random numbers
weren't necessary. I just needed lots of different numbers with no
particular pattern to them. OTOH, what I got was something like
3, 11, 3, 11, 3, 11, 3, 11...
which is obviously no use at all. The PRNG generates longer sequences in
a few cases, but most of the time it does not. And I somehow failed to
notice this.
In future, I'm going to use the PRNG library. No matter how stupid its
API is!
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
> I tried it myself with the program at the end of this post, and got a
> bit different of a result. The program printed:
I just found out that Windows includes a better RNG anyway, you call it with
the API function CryptGenRandom. More details here:
http://en.wikipedia.org/wiki/CryptGenRandom
It's a fair bit slower than rand(), but by making use of every bit returned
(rather than just testing the LSB) it is comparable.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> One of the basic things taught at school is that you should never attempt
> to make your own PRNG if you don't have extensive experience about the
> subject, if you want any kind of quality to it.
This method seems to work pretty well: http://xkcd.com/221/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Warp wrote:
> One of the basic things taught at school is that you should never attempt
> to make your own PRNG if you don't have extensive experience about the
> subject, if you want any kind of quality to it.
And even if you do. Knuth tells stories of his own attempts while writing
his semi-numeric methods tome, having thought he came up with a great RNG
and found it generated a couple hundred numbers before settling into a short
cycle of something like 3 or 4 values.
--
Darren New, San Diego CA, USA (PST)
Why is there a chainsaw in DOOM?
There aren't any trees on Mars.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |