Skip to main content

The lottery as a rational investment.

There is a prejudice that the poor play lotteries because they are lazy, can't save and are generally stupid and are hurting themselves by chasing the fantasy of winning instead of saving pennies. You know what? It's bullshit.

When I was in high school (about 13 years old), I once had a plan to make money: I would play the lottery. Here's the mechanism I had in mind.

I would play $1 in the quiniela. Quiniela pays $700 for each $1 you bet, and you have to choose a number between 000 and 999. My idea was: I can bet the $1 my parent give me every day, and there's a chance I make $700. If I had $700 I could buy anything a 13-year old kid may want. With $1? Not so much.

Of course you are right now thinking: What a moron! He has a 0.001 chance of winning and it pays 700 to 1, so it's a losing bet! Bzzzzzt!

Let's start with some simple simulation code:

import random

n = 476

for tests in range(10000):
    for w in range(1000):
        q = random.randint(0,999)
        if n == q:


Short explanation: run 10000 simulations of this process:

  • We play each day for 1000 days.

  • If we win, we stop.

  • If we don't win in 1000 days we stop.

  • We record the number where we stop.

So, I ran it. Here's a graph of the results


So, how many never won anything? In my data set: 3699 players out of 10000 never won anything.

How many actually lost money? 5030 players.

And how many won money? 4967 players won money.

2910 players won in less than 350 plays.

3 players got exactly even money, winning in their 700th play. For them, this was exactly the same as saving their money.

So, is it a good idea to play a lottery like this? It's a coin toss. Half the time, you end with no money. Half the time, you end with more money than if you had saved.

If you are betting disposable income (a sufficiently low amount that "it doesn't hurt"), it works out. You have a fair chance (50%) of a reward at least as good as saving the money, and a decent chance (25%) of a reward twice as good.

And you have a fair chance (50%) of losing money. But you would lose it very, very slowly and painlessly. ¿How well do you think stocks compare to that? ¿And what are the barriers to entry on both games?

In short: playing the lottery is not irrational, really, it's just a savings plan. It sure was a better idea than buying candy!

The Joy of Materialism

Recently I was delighted to read in Boing Boing posts by a modern Stoic. The delight was because it put into words something I had been grappling with for years and never really grasped: people have replaced philosophy with religion.

It used to be that someone would call himself a stoic, or a cynic, or a hedonist, or whatever, and others would understand that he was telling them the principles that rule his life.

A life philosophy! You could choose, from the buffet of the last 3000 years of thought, what you thought made most sense, and try to use it as a beacon to guide you through a (hopefully) happy life.

Nowadays, society seems to have rejected that idea, and the closest thing most people have is religion, following what his sect says, or atheism, defined by rejection of religion.

The main difference (as I see it) between a life philosophy and a religion is that a religion usually implies the others are wrong. If you are not of my sect, you will not be in heaven with me.

If you don't share my philosophy... well, I expect you will take a different path through your life than I would have taken. But if it works for you and doesn't hurt others, why should I give a damn?

So here's my life philosophy as I see it today. It's not how I saw it yesterday, and surely is not the same it will be tomorrow.

From now on, when I say I "believe" something, it's shorthand for "my personal life philosophy implies that". It should be obvious why such a shorthand is needed.

I am a materialist. No, that doesn't mean what you think it does, at least not in this context. What I mean is that I am not a dualist, or a spirituallist, I am not an idealist or a vitalist, and not a phenomenalist.

What it means is that I believe that reality is material. I don't accept that immaterial things have any sort of "reality". Or at least that their reality is of a totally uninteresting kind.

This means that I don't believe in souls. I believe the Turing test is a reasonable test for consciousness. I believe if there was an entity that acted like a human, we ought to treat it like a human. I believe I am not intrinsically different from a robot that could do what I do.

I believe the purpose of life is to have a good time. I believe everyone is as entitled to a good time as I am. I believe part of having a good time is being surrounded by happy people. I believe people that hurt others are a buzzkill and shouldn't be allowed to do it.

I believe in purpose, and I believe I create my own purposes and that makes them better than if they were given to me. I believe in being kind to others because they are all I have.

I believe in learning, because we are surrounded by wonders. I believe the Egyptians piled up lots of very heavy rocks. I believe Saturn is pretty. I believe giving the merit of those things to aliens or gods is an insult to the Egyptians and adds nothing to Saturn.

I believe in making things and fighting against local entropy. I believe that a certain end makes things better and more precious. I believe in love, because I know I feel it and it's precious.

So there.

Percentages considered dangerous: the Clarin story

Short intro for foreign readers: the largest newspaper in Argentina (Clarín) is in a catfight with the government. Therefore, we are treated daily to stories in the newspaper about how everything is terrible and the government is going to eat our children, and stories in the official TV channel about how Clarin wants to implant dancing contests and biased news into our prefrontal lobes.

The family subsidies are a recent policy that can be easily described: if you have a kid and you send him to school, you get a little money ($220). That's because having kids in school is a good thing. This has caused school enrollment to increase a lot in one year, meaning a ton of poor kids are now back in school instead of working in the streets or just staying at home.

Since it's hard for Clarín to go ahead and say that's bad, it has to find an angle. How about saying that inflation (which has been raising) is making the subsidies useless? It's an idea.

Having said that, it's hard to take this story and not say... dudes, you are giving biased journalism a bad name.

Here's the title and intro:

The raise in food prices has eliminated a big part of the family subsidies.

Depending on what indicators you use, the erosion can reach 92%

Taken at face value, that's pure nonsense. In order for that to be right, it wuld mean that the peso has lost 92% of its value and it has lost between 10% and 20% depending on what you compare it with.

What they did instead is take the cost of a basket of basic goods that has raised 36.2% (according to some estimates) and convert that raise into pesos. That's $404. Which is 92% of the family subsidies you get if you have two kids.

What's the problem? Well, of course the problem is that it makes no sense, because it's comparing two unrelated things.

Let's consider two moments in time, at the beginning of the subsidies and one year later. The basked of goods has raised from $712 to $1116.

Let's consider the case where that family only has the subsidies, both parents are unemployed and receive no help at all:

They have gone from covering 62% of their basic needs to covering 40% so they are obviously worse off now than a year ago. But not 92% worse, no matter how you cut it.

A bit more realistic: the family had some income other than the subsidies. Imagine only the mother works cleaning houses part time. That means she makes perhaps $500 discounting travel expenses.

So, a year ago, they made $940 and covered 132% of their basic needs, and now they cover only 84%.

But that ignores that pretty much everyone has had pay raises in the last year, precisely because of inflation. So assume she got a very modest raise: 10%, and she now gets $550.

That means she went from covering 132% to 89%.

Of course without the subsidies they would have gone from 70% to 49%! Try telling that mother that the subsidies have lost 92% of their value, and she'll laugh in your face.

Of course that means they are desperately poor, and yes, their salaries are worth less (if you take those numbers at face value, general inflation was much less than 30%).

But those $440 are something that was not there before. It is not a bad thing, and it is not a useless thing. And most certainly it's not a thing that has lost 92% of its value in a year.

Shame on you Clarín for trying to use "math" to confuse people.

Why you shouldn't believe anything you read. Including this.

A few weeks ago I was chatting with my father in law and (since I work with computers and must therefore know everything computer related) he asked me if I had heard of the 9 year old kid that worked for Microsoft as an engineer.

I said that probably, hiring 9 year olds to work as engineers was illegal, and that in most places to become an "engineer" you need to go to college, but any way it stayed in my head, like a pea in a maraca but anyway, I decided to check it out a bit.

First: no, there is no 9 year old working for Microsoft, as far as I know.

And then, a curious pattern appeared: there is not one story about that, there are several. And about different kids. And mostly in spanish-speaking media.

Let's check Mahmud Wael first.

Here's what InfoBAE says about him:

Mahmud Wael, un egipcio de 11 años y aspecto frágil, es el nuevo técnico de Microsoft gracias a su capacidad para resolver complejos cálculos en cuestión de segundos y moverse sin problemas por las redes informáticas


Mahmud Wael, a fragile looking 11 year old egyptian, is the latest Microsoft technician thanks to his ability to solve complex calculations in seconds and to move effortlessly through information networks.

If one actually bothers reading the story there's more: apparently Mahmud joined the American University in Cairo at age 9, and is now attending Cairo University for a degree in some computer-related area.

Now, I don't want to pick on InfoBAE because the same thing is reported in many other places (the previous links are just the first few that google gave me).

In fact, a bunch of those stories even say "With 11 years, he already works at Microsoft", which is somehow not in the InfoBAE story which is taken from the EFE agency.

Now... does he work at Microsoft? I bet he doesn't (or EFE would have mentioned it). It's just that when someone writes "Microsoft Technician" or "Microsoft Engineer" in english, well, that makes no sense in spanish, so the spanish media and readers are lead astray.

A Microsoft Certified Engineer is someone who has taken some Microsoft training courses and exams.

On the other hand, in most of the spanish speaking world, you can't call yourself an engineer unless you get an engineering degree from a university. In fact in Argentina calling yourself an engineer if you don't have one is illegal.

So, "Microsoft Engineer" is taken as "an engineer that works at Microsoft", because the alternative simply makes no sense.

What is the real story about Mahmud Wael? Well, let's check some egyptian sources, which is what all those newspapers should have done in the first place.

Here's Egypt Today's take on it from when he was 9.

Did he attend the American University?

Well, he had a scholarship from them to attend the Greenland International Language School, and attended one english course.

What about the "Microsoft Engineer" thing? He was planning to take the MCSD exams. Did he succeed? Well, Reuters says he got a MCTS.

An MCTS is not an MCSD, or an MCSE. In fact, just by saying someone has an MCTS (very impressive for an 11 year old!) you have no idea of what he knows, because a MCTS is about a specific product, and there are MCTSs for almost all of MS products.

So, in short: Mahmud is a very impressive and intelligent kid, but he is not an engineer, have a college degree or work at Microsoft.

And now the second case, Marko Calasan from Macedonia, which is the one actually mentioned to me.

And it's exactly the same story, except that he got a much better cert from MS than Mahmud, and he got it earlier.

Again the "works at Microsoft" thing seems to be exclusive to the spanish speaking media, and probably for the same reason.

Now, let's think about what this says of journalism. These stories were not hard to check. All you need is passable english skills and google. And if your english sucks, google can help you with that too.

But dozens of newspapers and sites just run with it because the "Microsoft hires (small age) kid!" is just too nice and people would accept it because hey, it's in the newspapers.

And you know what? I suspect that it's the same thing with a large part of what you read in the papers. If checking a tiny piece just because I have some peripheral knowledge about it says there are dozens of articles that are just wrong, what happens in all the areas where I am clueless?

Because we are all clueless in almost everything, and journalists are probably clueless about 90% of what they write about. It's not even a conspiracy, it's just ignorance amplified by their job description.

A short short scifi story

I wrote this for a contest at the New Scientist magazine. I thought what the heck, maybe someone will like it. And no, I won't explain it, because that spoils the whole thing.

There is no Such Thing as Free Energy

I wished a cold drink was still a possibility, and looked out, across the baked clay that used to be a swamp. The hatch closed and we started our long trip to the stars, cursing the inventor of the perpetual motion engine all the way.

Space Platform by Murray Leinster: rooting for the Death Star

I just finished reading Murray Leinster's Space Platform (in my new phone yay!).

You can read it too, if you want, because it's available, for free, from in any format you may need.

It's a very old-fashioned (published in 1953) scifi story, but what really shocked me was that in the 25 years between this and Star Wars (1978) everything changed.

Why? Because this is a book written from the perspective of workers building the Death Star.

Specifically, the main character, Joe, is working on building the gyroscopes for a space station which will be the first permanent artificial object in orbit... and is fully loaded with nukes.

Further, it's strictly a USA project (although there is a mention of it "being offered" to the UN) and the whole book is spent showing the courageous workers and soldiers fighting saboteurs in Arizona.

Replace USA by "the empire", workers and soldiers by storm troopers, space platform by death star, communists and anarchists by ewoks and rebels and... well, it's "Return of the Jedi", except the empire wins and all ewoks are killed in the end.

This short novel is completely acritical: US having the power to destroy any city in the world at will is good. All other countries being unable to retaliate is good. Trying to prevent it by any means? Bad and cowardly.

In just 25 years, though, films describing the situation exactly from the opposite point of view had every kid cheering for the saboteurs.

It's amazing that this book is closer in time to Star Wars than Star Wars is to today.

Reason #219 why you should learn english if you are a programmer

Here's pretty much the only place where you can buy Mark Summerfield's "Python 3" book in Argentina: Cúspide.

It costs $372.50 in pesos which is about $94 in dollars.

Oh, and you have to go to a book store to pick it up, or add shipping.

How much does it cost to buy that book in england and have it shipped to your door? $16. That's a whooping 17% of the local cost.

And no, it won't pay import taxes, because books are exempt.

And did I mention that the english version came out a year earlier?

So, if you don't learn english, you pay almost 6 times for the book, and wait a year.

Any programmer that doesn't know enough english is a third class citizen.

Épater le bourgeois: There is no god. Really.

203/365 The Atheist Bus The atheist bus, by stuartpilbrow, CC-by-sa

A while ago I wrote an article about gay marriage. (I am all for it, BTW). In it I said something like "since god doesn't exist ... " and boy did that bother people.

So, since I have twenty free minutes, let's see if I can explain why I say god doesn't exist.

Firt of all, a caveat. If you are religious, you have no right whatsoever to whine about me saying this. Why? Because I have no right to whine about people saying god does exist. It's called freedom of religion, people. You are supposed to like it.

This was triggered because I noticed there's a grand total of 2 (two) atheist characters on TV shows I watch:

  • Gregory House (MD): apparently a narcissistic bastard, but actually a nice guy (who is also a genius) with issues.

  • Dr. Brennan: a socially awkward genius.

Well, I am not a genius, so, let's consider some very reasonable arguments for god's lack of existence.

He's Ill-Defined

The Need For Answers The Need For Answers by Zach Stern, CC-by-nc-nd

The first thing you need in order to accept the existence of an entity is a definition for it. If you lack that, how can you say it exists at all? He could ring my doorbell and ask for a cup of sugar, and I still wouldn't be sure, because he could be re-defined at any time.

For example, is god omniscient? Is he allmighty? Is he the guy with the elephant head? Is he immaterial? Does he answer to prayer? Is he a he? Did he have a kid? Did he have his kid by turning into a swan before going on a date?

Since depending on what godist you ask he will answer at least one of those differently, I have to declare his existence impossible.

Of course we could try to accept the definition of one godist club and try to see if that specific entity exists, but that doesn really work either, because god fans have a tendency to move the goalposts. What's "the word of god" becomes later an allegory, depriving us of any evidence on which to base our enquiry.

Mostly, godists say that the know god exists because they feel it in their hearts or something similarly harebrained. Come on, if I told you I feel the easter bunny in my kidney, it would make about as much sense.

The Excluded Middle and Popularity

God made me an atheist. God made me an atheist. by Andrea Lodi, CC-by-nd

Either something is true or its opposite is. Either you ate some of that cake, or you didn't. Either god exists or he doesn't. Easy, right?

But why couldn't god exist? Well, let me ask you, why don't the other gods exist? You are a zoroastrian: why doesn't Zeus exist? You are a mormon, why doesn't Quetzalcoatl exist?

Every godist is perfectly happy with the other gods not existing, so it's not exactly a ground-shaking notion. It's clear that whenever you hear anyone talk about a religious majority, he is full of crap.

Repeat after me: you are not part of a religious majority, because most people believe your god doesn't exist. We atheists are just smarter and more consistent.

And no, you can't retreat into "oh, muslims jews and all christians believe in the same god" because that's nuts. Jews believe in a god that doesn't let them eat ham. Mormons believe they are ordered to use magical underwear. Catholics believe they eat meat wafers each sunday, it's just that it looks, feels and tastes like a cracker, but it's "really" (super)human beef. For each group, the other's beliefs are barbaric and (if they are honest) a little nuts.

No, I am not saying you individually are nuts, you nutcases, I am saying you are conditioned to believe your particular idiosyncrasies are less nuts than average, but they aren't, just like my dad's habit of putting mayonnaise in the soup was nuts and my belief that Unión de Santa Fe will someday win a tournament is nuts.

IOW: mostly harmless, but nutty anyway. OTOH, some people's beliefs make them believe that killing albino kids is a proper behaviour so some of you godists are really, really nuts, ok?. Not all of you, but those who aren't should take a good hard look at what believing in invisible friends does to some people.

It's Unethical to Believe in Heaven and Hell

Oh Noes! Atheists! Oh Noes! Atheists! by Sean Bonner, CC-by-nc-sa

Consider my three year old kid. There is a rule that he has to eat a reasonable amount at dinner, and if he does he can watch one TV show before bed as a reward.

In universe A: One night he's very tired, so he doesn't really want to watch TV, he wants to go to bed, but he still eats his dinner because it's good for him.

In universe B: One night he's very tired, so he doesn't really want to watch TV, so he doesn't eat his dinner because there's no reward.

Believers will tell you that human nature is B. That if there was no promise of carrot (heaven) and stick (hell) humans would have no morals and would act like insane hedonists, hurting each other in a frenzy, and that we only avoid such a terrible fate because of the civilizing infuence of the churches and the morality induced on us by religion.

I say bullcrap. I say I prefer if my kid does what's good for him not because he's expecting a reward or (worse!) because he's scared of punishment, but because he understands that if he eats his dinner he's going to be strong and healthy, and that it makes me happy and that he wants me to be happy because he likes me.

Of course, being a three year old, he sometimes doesn't want to eat his dinner. So I try to convince him. But if he doesn't, he doesn't, and there's no TV, and there's no tantrum, and he gets a kiss good night.

The concept that there is a lot of people who honestly believe that they are moral beings only because there's an invisible guy who will hurt them if they aren't scares me. I find it deeply repulsive. I find religion's promise of eternal (or even temporary) punishment in the afterlife repulsive and creepy.

If you believe in an afterlife, and you believe in heaven and hell, and you act nice because of it, you are a creep. You are, like religious people like to say, a creep in your own heart. You are not good. You are evil but just think you can't get away with acting out your evil. You are a chicken. If the deity you believe in actually exists, he knows it, so you are screwed anyway.

I prefer to be good for my fellow men because there's nothing else beyond. If there was a heaven, then we live in a crappy waiting room. No! We live in the real world. What's beyond is fiction or guesswork, you can't count on it, you can't throw away real life for it.


God vs graffiti vs property rights vs drippy markers, Soho, London, UK.jpg God vs graffiti vs property rights vs drippy markers, Soho, London, UK by Cory Doctorow, CC-by-sa

You are a bit nuts and your invisble friend doesn't exist. You don't need to get a life because you already have one, you just need to stop asking for seconds and eat your dinner. Have fun.

Cooking for nerds

You are a nerd. I know that because you are reading my blog. You probably don't cook. That is stupid. Let me explain why.

Cooking is easy

You may be intimidated by those who cook and make it look complicated. Don't believe a word they say. You can cook a perfectly fine meal for 1 to 4 people in half an hour.

For example, if you have dry pasta, any kind of protein (chicken, seafood, ground beef, sausages, chorizo, fish, whatever), a bouillon cube (vegetables, beef, whatever), garlic, onion and/or anything like it, and a glass of wine (optional) you can cook it like risotto

And here's the best part: read that recipe, and here's all you need to know to cook it:

  • Toast the dry pasta in kinda hot oil (olive oil if you have it, or whatever).

  • Add chopped onions, garlic, peppers (or whatever) for 3 minutes.

  • Add 1/2 cup of wine (it says white, but red wine will work, it will just make it taste "heavier" and change the colour). If you don't have wine, use broth. Wait two minutes or so until it's almost dry.

  • Add broth slowly while stirring.

  • When the pasta is still kinda hard, stop adding broth, add protein (chopped small so it cooks completely) and a bit more broth and lemon juice (or not).

Or you can do this:

  • Sauteé onions, garlic whatever and protein, then put it aside and save it.

  • In the same oil, toast the pasta. This makes the pasta tastier.

  • Re-add the protein and vegetables, then add wine and broth slowly

  • When the pasta is the way you like it, eat it.

See what I did there? I did it almost exactly the other way around. And you know what? It's still going to taste good. Why? Because cooking is very fault tolerant.

Yes, you will hear all the time about the perfect point for this, and the perfect seasoning for that, and ... it's 90% bullshit.

Sure, if you overcook the pasta it's going to be soggy crap, but you can avoid that by being minimally vigilant about it and buying a freaking $4 kitchen timer

Cooking is fun

Once you get over the notion that it's hard, cooking is easy to enjoy.

If you have a kid, he can help. If you have a spouse, he/she will like that you are taking care of the meal.

It's great for unwinding after being stressed. Strangely, chopping garlic relaxes me.

Have a microwave and a 3 year old? Then you can do this:

In one bowl mix:

  • Two beaten eggs

  • Add vanilla (or don't)

  • Add a bit of butter (or vegetable oil)

In another bowl:

  • 1 cup of regular all-purpose flour (or whole wheat flour)

  • a bit of baking powder

  • a bit of salt

  • half a cup of sugar

In one of those bowls add something else. If it's moist, add it with the eggs and such, if it's dry, add it with the flour and such.

That "something else" can be chocolate chips, walnuts, shredded carrot, bananas, sliced apples, jam, whatever.

Once each bowl is mixed, mix them together a bit until they "mesh". Don't work it too hard or the result will suck.

Then get two (or three, or one, or four) mugs (or cups, or muffin trays, or anything that's microwave-safe) and fill it half-way with the resulting batter.

Microwave it until it looks good, then eat it. If you are not sure if it's cooked, stick a wooden toothpick in it and see if it's dry when you pull it.

Your 3 year old can take care of the dry bowl (he does similar things in kindergarten, you know?) as long as you help with the measures. And most importantly: he can take care of starting the microwave, so tecnically he can say he cooked it (3 year olds are very into technicalities).

Again, see what I did with that recipe? You can replace almost any ingredient with something else (I don't recommend not using eggs, though) And it will probably work.

And you will end with a flour-covered kid, which is a bonus, because then he won't make a fuss about his bath.

Cooking is good for you

I have high blood pressure and I'm fat. But you know what? I have not gained any weight since I started cooking for myself, 10 years ago. I gained a lot before that, though.

Now I can cook semi-healthy food for me, and do it with the low sodium I need. Sodium is a habit, so after you are eating low sodium for a few weeks you don't really miss it.

If you are a nerd, you probably are a bit too sedentary, so eating "right" will help you.

And most importantly, you know what you eat. Sure, you also need to take care of what ingredients you buy, but did you know that pizza has a like 400% markup? And that you can do a reasonably healthy pizza in, like, 40 minutes of work?

The only trick is starting 3 or 4 hours early.

But if you use home-made dough, chopped tomatoes for sauce, garlic, peppers, and not too much cheese... it's not a terribly unhealthy meal.

And of course, you can always do a salad. Come on, how hard could that be? It's chopping things up and piling them, dude!

And it can be tasty and filling. You just need to do a lot of it ;-)

Cooking is cheap

A milanesa (sort of a breaded steak?) in a cheap restaurant wil cost you about $25. For that money you can make 7 or 8 at home.

A good piece of prime meat in a restaurant? $50. That buys 2 pounds of prime meat in the market for you to cook.

A reasonable lunch menu for office workers costs about $30. For that money my family of 3 eats twice. And better. And more.

You can make yourself the most awesome sandwich in the world for under $10, with anything you imagine in it and take it to the office.

And, most importantly...

Cooking is Applied Nerdiness

Cooking gives you a way to easily experiment with real-life chemistry, gives you something concrete to show for your effort after a whole day coding things you can't really show your family.

Why does ham taste well with apricots and not with apples? Or does it? How about chili? Does it go well with sour cream? How about pepper on a strawberry?

But forget about adding: What can you remove from a recipe and still make it work? What can you replace? If you can make banana bread, can you make banana croissants? (no you can't, they taste awesome but they look ghastly)

How can you go through life without wondering if you can really cook fish with just lemon juice? Exactly how long do you cook rice in your microwave so it looks creamy and taste great without removing excess liquid? Did you know you can steam 2 pounds of potatoes in 10 minutes with a plastic bowl and some plastic film, and they will make the most awesome mashed potatoes you ever tasted?

Your kitchen is an awesome place. Instant noodles suck.