Drawing Blanks

Premature Optimization is a Prerequisite for Success

Archive for December 2012

A loaded die study

leave a comment »

I got a set of handcrafted dice for Xmas. They look like this:

DSC00555 (640x550)DSC00554 (640x481)

They are wooden, the shapes are obviously imperfect, and the dots are made of metal.

I immediately suspected that they can’t be well balanced and decided to conduct a little study, that turned out to be fun and instructive.

The first experiment I did was dropping the die into water. It appeared that the die is lighter than water and it always floats the 1 side up and the 6 side down:

DSC00560 (640x427)

[Side quest: A perfect cube with the density of exactly 1/2 of the density of water floats in water. Will it float side-up, edge-up or vertex-up? This problem is too tough for me, and I don’t have a solution.]

Anyway, after the float test it was evident to me that the die is biased in the 1- 6 direction. But by how much is this imbalance affecting the outcome of rolling the die on the table?

My next test was the Roll Test. I rolled the die 121 times. Why 121? I wanted a number that is close to 100, close to a multiple of 6 and close to a perfect square. That is because I was pretty sure I’d be able to compute the sigma on a napkin and that would be it. Both 120 and 121 are good numbers. But after I did 120 rolls I thought, why don’t I do one more.

Here are the results of my 121 rolls:

1 2 3 4 5 6
27 19 19 20 21 15

r

Right, 1 and 6 are obvious outliers… ??? … But they are within the 2-sigma range… But I’m more than confident in my alternative hypothesis! Like a true researcher, I’m going to find a way to confirm it! Winking smile

So, do I do another 100 rolls? No way, that would be no fun! I’m going to pretend that I’m not dealing with a stupid die, but rather with a particle accelerator, and that I’m over the budget, so this sample is all I have. I’ll do various stats tests on my sample, and I’m going to find one that confirms that this stupid die is loaded!

Sadly, both Chi-square and Kolmogorov-Smirnoff yield p-values about 0.5 that is 10 times greater than what I need in order to reject the hypothesis that the die is fair.

But I’m not giving up. Why was I doing all those tests that attempted to refute the null-hypothesis without having any information about my alternative hypothesis: that the die is biased specifically towards 1 and specifically against 6. And why was I doing all those old-fashioned tests at all? It’s not 19th century and I have a very capable computer at my disposal. I can simulate whatever I want.

Results:

Alternative Hypothesis
(out of 121 rolls)
p-value
At least 1 number appears more that 26 times 0.37
At least 1 number appears more that 26 times AND at least 1 number appears less that 16 times 0.3
Exactly 1 number appears more that 26 times AND exactly 1 number appears less that 16 times 0.2
The number ONE appears more that 26 times AND the number SIX appears less that 16 times 0.01

 

So I guess I could now conclude that the die is biased specifically towards 1 and specifically against 6. But should I?

The next step should be checking how significant this bias is for some actual game. I’d need to simulate a game with a realistic bet and see how much money can be won using this die within a realistic timeframe.

I used R for the simulations. Below is the piece of code that does that. Happy New Year!

Read the rest of this entry »

Written by bbzippo

12/31/2012 at 2:51 am

Posted in fun, math, science

Red vs. Green

leave a comment »

image

This is from Microsoft Excel 2010.

And I have a confession to make: I can hardly tell Good from Bad… like 1% – 6% of all human males I have a slight defect of color vision. We are not a threat to society: we can tell apart the traffic light signals and other color-based discriminators used in machinery, weaponry etc.

So why don’t UI designers take us into consideration? I’m sure there is a ton of research on creating dichromacy-friendly color palettes.

The RGB values for Good are 198, 239, 206. For Bad: 255, 199, 206. Are you kidding? How can anyone tell these apart? Now let’s increase saturation (+40 in Photoshop):

image

Now I can clearly see the difference. Good RGB: 200, 255, 130. Bad RGB: 255, 199, 206. See, Bad wasn’t affected by the saturation boost. And Good became… greener and lighter.

… Lately I’m sooo disappointed by what Microsoft is doing in UI/UX. It’s cargo cult… Failed attempts to copy Apple… I’m so glad Steve Sinofsky is no longer there… I wanted to write a huge rant about Windows 8, but I don’t even know where to start.

Happy Holidays!

Written by bbzippo

12/26/2012 at 2:35 am

Posted in Uncategorized