Showing posts with label Misc. Show all posts
Showing posts with label Misc. Show all posts

Wednesday, April 27, 2011

Heads or Tails? or: how to lose money at the roulette table

I've always wondered how many heads/tails you'd get in a row if you could just keep flipping coins forever. The other day I was bored so I put together a stupid matlab script to try it out (leaving out the "forever" bit).

It's obvious that in theory you could get a never ending series of heads or tails, but in practice that is infinitely unlikely to happen, so I just wanted to get a feel for a "reasonable" figure in terms of how many repetitions one should expect to experience if one actually started tossing coins (or betting money on red/black at the roulette) for a very long time.

Out of 100 million series of coin tosses (where a series is defined by an uninterrupted streak of heads or tails) the longest streak of identical outcomes was 26 (I wanted to try with a billion series but was taking too long).

That means that if you go to a casino to make money doubling bets on red/black (the so-called Martingale strategy) and you are particularly unlucky you might have to flush out 20*(2^25) = 671,088,630 $ (a single bet is usually at least 20 $) on your last bet to actually make a profit (plus all the money you spent to get there).

If you play smart though, and you wait for 5 reds/blacks in a row before you start betting against that, then you can get away with a last bet of only 20*(2^20) = 20,971,520 $ (that's 20 millions!).

Saturday, February 27, 2010

Russel's antinomy and stackoverflows

Russel's Antinomy goes like this (an extract from Gödel's proof):
Classes seem to be of two kinds: those which do not contain themselves as members, and those which do. A class will be called normal if, and only if, it does not contain itself as a member; otherwise it will be called non-normal. Let N by definition stand as the class of all normal classes. We ask whether N itself is a normal class. If N is normal it is a member of itself (because by definition it contains all the normal classes); but, in that case, N is non-normal because by definition a class that contains itself as a member is non-normal. On the other hand, if N is non-normal it is a member of itself (by definition of non-normal); but, in that case, N is normal, because by definition the members of N are normal classes. In short, N is normal if, and only if, N is non-normal. It follows that the statement "N is normal" is both true and false.

By reading this sort of stuff, we get reminded how all the stuff we work with as software engineers, comes from Mathematicians.

Anyway, this is what I came up with, inspired by the above:

public class NonNormal
{
   NonNormal _nonNormal = new NonNormal();
}
Now you just instantiate NonNormal and you'll get a pretty sweet stackoverflow.

I don't know about you, but this looks like a pretty elegant fuck-up to me.

Thursday, December 10, 2009

What a bunch of ...

... bullshit!

The developers count on the stackoverflow ad page is clearly increased at random.

The count is being increased in a recursively called function at random intervals. Here's the javascript:


$(function(){
       
        var visitors = 5373966;
        var updateVisitors = function()
            {
                visitors++;
                
                var vs = visitors.toString(), 
                     i = Math.floor(vs.length / 3),
                     l = vs.length % 3;
                while (i-->0) if (!(l==0&&i==0))
                    vs = vs.slice(0,i*3+l)
                       + ',' 
                       + vs.slice(i*3+l);
                $('#devCount').text(vs);
                setTimeout(updateVisitors, Math.random()*2000);
            };
        
        setTimeout(updateVisitors, Math.random()*2000);
        
    });

P.S. Posting this from google SideWiki - kinda cool

in reference to: http://inedomedia.com/stackoverflow.aspx (view on Google Sidewiki)

Friday, April 10, 2009

Start Using WikiSearch Already!

When I run a search I often have a peek at other people's favourite search results for that given search (from the "see all notes for this WikiSearch" link) in the hope I won't have to spend precious seconds/minutes to find what I am looking for. Unfortunately - even if WikiSearch has been out for a while now - the usual result is the void.

It's well known that any respectable developer spends a fair share of time looking up stuff on Google. Wouldn't it be easier for everyone if we all started using WikiSearch? 

Telling the good stuff from the crap would be much faster.

Tuesday, January 13, 2009

Ask a Google Engineer - He Won't Answer

Recently I noticed a very promising initiative on Google Moderator: Ask a Google Engineer.

Geeks are encouraged asking questions to Guido Van Rossum & Co. with no limitation - from "Do you use Google toilet paper" to the infamous interview question "How would you sort 1 million 32-bit integers in 2MB of RAM?".

Turns out most of the question (roughly 1500 in total so far) asked by people (roughly 5000 so far) are silly complaints about how limited is this or why it's not possible to do that in gmail.
 
The rest are pretty much questions studied to impress Mr.Van Rossum with very elaborated Python blabbering or people trying to understand how to find the answers for the questions they are voting. 

But really - where are the answers? There are none (almost). Seen the amount of crap they're getting they're sitting it out to enable questions to be filtered by people votes.

Not exactly a success so far I'd say (maybe also because Google moderator kind of sucks imho)!

Monday, December 29, 2008

Testers are cool at prime numbers

A software tester, a software developer, and a project manager are told: 
“All odd numbers are prime”
The Developer says:
“Let's see, 3 is prime, 5 is prime, 7 is prime - looks like it‟s true”
The Project Manager says:
“Let's see, 3 is prime, 5 is prime, 7 is prime, 9 is prime, 11 is prime –looks like it‟s true.”
The Tester says:
That's silly, nine is a non-prime odd number - looks like it's bullshit”

I recently heard this very sad anecdote while attending a lecture about Software Testing. 

Everybody (except maybe a Test Manager) knows the developer would look up prime numbers on google before even trying to answer.

Anyway - here's a good resource about odd prime numbers humour.