The St Petersburg phenomenon. The paradoxes of probability theory. - page 3

 
Dmitry Fedoseev:

With a bet of 4, it seems to be a level playing field (if I understand the rules of the game correctly).

if(MathRand()/32768.0<0.5)  ...
if(MathRand()%2==0) ...

or

if(MathRand()%2) ...

or

if(MathRand()<16384) ...
 
Nikolai Semko:

or

or

Last option. The remainder of the division of the curve - checked.

 
Dmitry Fedoseev:

Last option. The remainder of the division of the curve - checked.

Why is it crooked? It's not crooked, it's just the compiler that swears, but it swears in vain.

To avoid it, you can do this:

if(bool(MathRand()%2))  ...

It's not hard to check it:

int OnStart()
  {
   for (int i=0; i<10; i++) if(bool(MathRand()%2)) Print(i);
  }  
 
Nikolai Semko:

Why is it crooked? It's not crooked, it's just the compiler that's swearing, but it's swearing in vain.

You may do the following to avoid it:

It's not hard to check it:

We did, the randomness wasn't random at all. It was long ago, back at the 4th forum. I don't remember exactly how they checked it, but the picture was quite sinusoidal. It's not because the compiler would scold us.

 
Dmitry Fedoseev:

We checked, the randomness wasn't random at all.

What are you talking about!

MathRand()%2 only takes two values - 0 or 1.

 
Dmitry Fedoseev:

We checked, the randomness wasn't random at all. It was a long time ago, back in the 4th forum. I don't remember exactly how it was checked, but the picture was quite sinusoidal. It's not that the compiler is scolding at all.

Yes, I got your point. Indeed, I saw a drop-out from a random process. The rand() algorithm is obviously far from being perfect.
Yes, then this variant, especially it is the fastest, since there are no mathematical operations:

if(rand()<16384) ...
 
Nikolai Semko:

What are you talking about!

MathRand()%2 takes only two values - 0 or 1.

But you can sum them up or not take the remainder from two.

 
Yes, the most normal option with if(rand()<16384), I didn't think of that))
 
Dmitry Fedoseev:
Yes, the most normal variant with if(rand()<16384), something did not think))

You can make some more twists and turns:

if(rand()<1<<14) 

which is exactly the same, but in a way that most people don't understand. ))

 
But what if it's 0 to 5, or 7, or any other number? You still have to divide by 32768.0. Or are there options?