On Fri, Sep 25, 2009 at 5:16 PM, Semih Ozkoseoglu
<ozansemih / hotmail.co.uk>wrote:

>
> And Josh,
>
> > Hi, it is giving me the output that I would expect, here is a image
> > showing
> > how I calculated it, and I ran the program 3 times with results very
> > similar
> > to what I calculated they should be.
> > http://img132.imageshack.us/img132/8939/roulette.png
>
> I get the exact same results with you but what I dont understand is why
> you think that the results are normal. I dont understand why it looses
> twice as much when you bet randomly (if its not the problem Paul
> mentioned above). It would be great if you can tell me how you
> calculated what the results should be.
>
> Thanks.
> Semih
>
> --
> Posted via http://www.ruby-forum.com/.
>
>
Here is the formatted explanation:
http://img38.imageshack.us/img38/8939/roulette.png


And for completeness sake, here is a the unformatted explanation:

Okay, so you are adding 1 for every win (w), and subtracting one for every
loss (l), which gives n*w-n*l , which can be simplified to n(w-l) So for a
pair of win and loss, at some given number of attempts, n, we get the
formula.
[math]f(w,l) = n(w-l)[/math]

You want to know why it's value is approximately twice as large, so let's
compare the two functions by dividing them. We will calculate f for bet_rand
and bet_red, and divide them by eachother.

First we need to find the likelihood of winning and losing, our w and l, for
bet_rand and bet_red.

bet_rand compares color_01 and color_02, each of which are randomly selected
from values 0 through 36 (thirty seven possible values). So there is a 1 in
37 chance of color_01 being zero, and for that case, there is a 1 in 37
chance of color_02 being zero. And there is an 18 in 37 chance of color_01
being red, and a 18 in 37 chance of color_02 being red. And there is an 18
in 37 chance of color_01 being black, and a 18 in 37 chance of color_02
being black.

So this gives us [math]\frac{18}{37} * \frac{18}{37} + \frac{18}{37} *
\frac{18}{37} + \frac{1}{37} * \frac{1}{37}[/math]

Which comes out to [math]\frac{649}{1369}[/math]

And the likelihood of losing is l = 1 - w = [math]\frac{720}{1369}[/math]


Now, for bet_red, color_01 will always be red. So there is a 0 in 37 chance
of color_01 being zero, and for that case, there is a 1 in 37 chance of
color_02 being zero. And there is an 37 in 37 chance of color_01 being red
(because it is manually set to red), and a 18 in 37 chance of color_02 being
red. And there is an 0 in 37 chance of color_01 being black, and a 18 in 37
chance of color_02 being black.

So this gives us [math]\frac{37}{37} * \frac{18}{37} + \frac{0}{37} *
\frac{18}{37} + \frac{0}{37} * \frac{1}{37}[/math]

Which comes out to [math]\frac{18}{37}[/math]

And the likelihood of losing is l = 1 - w = [math]\frac{19}{37}[/math]



So now we have our probabilities to feed the function.

Now, we need to find a meaningful way to compare them. What we will do is
compare their values for some given n, we noticed that bet_rand seemed to
grow about twice as fast as bet_red. So we will divide bet_rand's limit as n
approaches infinity by bet_red's, and see if it comes out to about 2. This
gives us

Our formula
[math]d(w,l) =
\frac{f(w_{bet\_rand},l_{bet\_rand})}{f(w_{bet\_rand},l_{bet\_rand})}[/math]

Fill in the values.
[math]=
\frac{f(\frac{649}{1369},\frac{720}{1369})}{f(\frac{18}{37},\frac{19}{37})}[/math]

Substitute the value of f(w,l)
[math]=
\frac{n(\frac{649}{1369}-\frac{720}{1369})}{n(\frac{18}{37}-\frac{19}{37})}[/math]

At this point, we can see that the value of n is irrelevant, as it cancels
itself out.

[math]=
\frac{(\frac{649}{1369}-\frac{720}{1369})}{(\frac{18}{37}-\frac{19}{37})}[/math]

And simplifying, we get.

[math]= \frac{71}{37}[/math]

[math]\approx 1.91891891891892[/math]

So we have shown that we can expect bet_rand to grow (in a negative
direction) about 1.92 times quicker than bet_red.