About lelanthran

Researcher, developer, and sometime critic.

Blackjack basic strategy

Gambling Games

There are two types of gambling games:

  1. Those that, even after the game has started, allows the player make decisions.
  2. Those that, after the game has started, doesn’t allow the player any further decisions.

An example of the latter are slot machines – once you put your money in and hit the button, no further decisions from you can influence the outcome. Roulette is like this as well: once the dealer announces “no more bets”, you can only watch and hope that you will win.

An example of the former are games like poker, where even after you start the game, you can decide to draw more cards, bet more money or simply give up and lose whatever you already bet. Blackjack is also an example of a game that lets the player steer the outcome slightly – after you start the game, further actions taken by the player  can cause a win or loss.

Enter Blackjack

I’m not going to give a full treatment of the rules of blackjack (which, at any rate, differ from casino to casino) nor the theory behind it in a tiny blog post. I’m just going to point out that there are some actions that the player should take in certain conditions that provide the best possible chance that the player will win.

As an example, lets say the dealers face-up card is a five, and the players two cards are a pair of aces. In this situation, the best odds for the player are to split the aces. Or if the dealers face-up card is a nine while the player has an ace and an eight, then the best course of action would be for the player to stand.[1]

The rules are simple (although they differ slightly based on what the different casinos allow), but they are horribly difficult to remember, especially when the test involves going to a casino and playing for money! Luckily, your blogging friend has some assistance in this regard. I’ve written a simple online blackjack training program. You play blackjack, and it tells you whenever you make a choice that is sub-optimal.

Unlike other blackjack programs which even do your counting for you, this program tries to make you do all your own work, hence you should be prepared once you hit the casino for real.

Note that it is still slightly incomplete – I need to implement “splitting” – but the advice is given, and the game maintains a bankroll for the player, and the player can hit/stand/double/surrender. As usual, let me know if this is useful to you; it’s hardly worth my time to implement the “splitting” if no one is using this program.

[1]Note that I’m ignoring the issue of insurance. Insurance is a suckers bet, and should be only taken if you have been keeping accurate count of the cards going past. But if you’ve been keeping accurate count of the cards going past, you won’t need the insurance anyway. So don’t take it. Ever.

The death penalty and its effect on crime.

Well, I got interested in this little question some time back. Whenever the headlines are filled with a gruesome enough crime, the newspapers are inundated (in their “letters” section) with calls to “Bring Back The Death Penalty”. Of course, the purpose of the justice system in most countries, in the event that a criminal has been proved to be guilty beyond reasonable doubt, is not to exact revenge on the criminal on behalf of the victims, but to ensure that the crime is punished, and (pay attention, this is the important bit) to rehabilitate the criminal.

Hence, in South Africa, our prisons are run by the department of Correctional Services (note the emphasis!), and not by the department of Revenge Meted Out Services. Most other countries follow something similar – the idea behind law and justice is to make society safer for everyone, and not to simply punish criminals, nor to use the system as a means of revenge. This brings to the fore the question “Is capital punishment a significant enough deterrent to capital crimes?”. In other words, does having and handing out the death penalty frighten criminals into not becoming criminals?

There are basically two sides to this (I’m only going to mention both, not argue them):

  1. The death penalty does reduce crime.
  2. The death penalty has no effect on crime.

A number of arguments in support of either side eventually makes it way around the papers (via the “letters to the editor” section), with the most visible ones being:

  1. Criminals are afraid to commit crime if they think they will be killed if caught, hence crime rates drop.
  2. Criminals think they won’t get caught (which is why they commit in the first place), hence have no fear of the death penalty.
  3. A person who is terminated by the state would not get another opportunity to kill again.
  4. A death penalty may actually raise the number of actual murders, as then criminals will have to ensure that all witnesses (for example a rape victim) are killed. With no death penalty a witness or two may survive.
  5. Criminals are more likely to snitch on their accomplices when caught if there is a possibility that their sentence would be reduced from “death” to “life imprisonment”.

Now I’m pretty certain that murderers don’t typically complete a course in statistics, so I decided to look it up for myself. Luckily, there are some countries that have and routinely hand out the death penalty, and some countries that don’t. So if there was a relationship between handing out the death penalty and crime rates (whether a positive or a negative one), we should be able to tell.[1]

In other words, the list of the safest countries should contain more death-penalty countries in the list, than a list of most dangerous countries if the death penalty were to make the society safer. The corollary (that the list of countries that hand out the death penalty should contain more countries that are safer) is a topic for a new blog post sometime next week.

So, we know what to expect: that the list of safest countries should contain less death-penalty-countries, and that the list of most dangerous countries should contain fewer death-penalty-countries. Lets actually check the both lists and see.

Note that I got the data on homicide rates from here, and the list of countries that hand out death-penalty sentences from over here

Lets start by looking at top ten the countries with the highest rates of crime. Lets check how many of them have the death penalty.

Country Murder Rate Death-Penalty No Death-Penalty
El Salvador 71 X
Honduras 67 X
Jamaica 58 X
Guatemala 52 X
Venezuela 49 X
Trinidad and Tobago 43 X
Colombia 35 X
South Africa 34 X
Belize 33.4 X
Brazil 25.2 X
Totals 4 6

It seems, of the most dangerous countries, that four of them hand out the death penalty, and six of them don’t.

How about the top ten safest countries (i.e. those with the least crime)? How many of them have the death penalty?

Norway (excluding attempts) 0.6 X
Oman 0.59 X
Lebanon 0.57 X
Morocco 0.53 X
Brunei 0.5 X
Hong Kong 0.49 X
Japan 0.44 X
Singapore 0.38 X
Iceland (excluding attempts) 0.31 X
Liechtenstein (excluding … 0 X
Totals 4 6

Hmm … it seems that this weeks  question is answered – the death penalty makes no difference to the top ten most dangerous or safest countries.

But is this actually truly reflective of reality for those countries that are not in the extremes? Perhaps we should rather check all the countries to see, on average, which are safer to live in – the death-penalty-countries or the non-death-penalty countries.

Check back next week for the answer to the question “On average, do the countries with more crime hand out the death penalty? Is there a relationship between the crime rate and capital punishment?”

(To Be Continued …)

[1] As the death penalty is only handed out for actual murder, I use the word “crime” to mean “homicide”. Not even the most ardent death penalty supporter would expect the death penalty to be handed out for shoplifting, hence there is no need to look at shoplifting statistics to see if they correlate with death penalty.

Downloading videos via torrents

See the preliminary data gathered.

Many of the torrents being uploaded to popular sites are actually fake. Very many of the comments by the users of such sites express anger and dismay that there are people out there who seed fake torrents (ironic, since these same users are infringing copyright by downloading the torrent).

For the most part, as far as I can tell when surfing the torrent search sites (purely in the spirit of scientific enquiry, you understand), the fakes are simply files that can be read with only a single video player, and the fake videos display nothing but a message informing the viewer where the video player can be purchased. In other words, the torrents are spam, but you can’t tell that until you’ve exhausted your entire bandwidth downloading this fake file.

As there is a financial incentive for these companies to keep their torrents highly visible, it’s obvious that they are the ones seeding the fakes, hence you see the latest Hollywood movie for download with approximately 13000 seeds and a few thousand leeches, you assume that the torrent must be legit because:

  1. Surely there cannot be 13000 people are are seeding a fake file, and,
  2. Even if 13000 people are silly enough to do this, surely the few thousand leeches must mean that the torrent is legit.

Sadly that is not the case – a botnet can easily exceed 13000 computers, and the spammers behind this obviously know that they need to leech off the seeders or else the downloaders will get suspicious. Hence the spammers will both seed and leech at the same time. If this is the case, then they obviously will prefer to leech as little as possible to save what they can of their bandwidth to allow their victims to download.

Since I figured that they would have a set percentage of their botnet as leeches, I gathered a little data from isohunt – see the above-mentioned pdf file for the actual data. My conclusions?

  1. With the exception of a single torrent, all of the negatively rated torrents (i.e. the fakes) had leeches that were not more than 28% of the seeders.
  2. With the exception of a single torrent, all of the positively rated torrents (i.e. legit torrents) had leeches that were not less than 30% of the seeders.

The outliers are statistically expected – some of the fakes will have actual people downloading (taking the percentage of leeches higher) while some of the legit torrents will have more people downloading than seeding anyway (taking the percentage down).

So, in order to determine a torrents legitimacy for seeds of 10k or more, you can rely on the percentage of leeches as being roughly indicative of it’s legitimacy. In other words, any torrent which has a ratio of seeders:leechers that is around  10:3 is probably a fake.

I also note that the sample size (98 torrents ordered by number of seeds) is a little small, while the sampling (all from the Video/Movie category) is not random at all to draw firm conclusions from. The only really safe conclusion one should draw from this result is that it indicates that further research might be useful.

Biological clock

Ever wished you could track your menstrual cycle without needing to count days on your fingers? This tiny project here should do the trick.  It displays those days of the cycle that a women is most likely to conceive, if she sets the start of her cycle every month.

It’s easy to understand. If intercourse takes place when the needle is in areas shaded in green then conception is unlikely, the areas shaded in pink are more likely to conceive a female and the areas shaded in blue are more likely to conceive a male. It looks like this:

icon for bioclock

Biological clock screenshot

The black needle on the clock display the current day of the cycle, the red needle at the 6-O-clock position displays the start of the cycle. Whether your cycle ends exactly at 28 days or not, simply select the first item in the menu of this application to reset the cycle (the minute your new cycle starts, that is).

Send me email if you use this; if significant demand exists I will most likely make the following changes:

  1. Fix the pink/blue ratio to be equal in area and to fade in/out gradually.
  2. Change the calculation so that the clock will adjust to your personal cycle (for example, if your cycle is generally 26 days, the clock must use 26 days as a full cycle, and not 28).

The hypothesis for why certain times of the month are better for conceiving a male and certain times for conceiving a female, look at this research proposal over here.

Software Project Management

The Polaris Missile project was developed in the late 1950′s. The project involved 250 major contractors, over 9000 subcontractors and hundreds of thousands of individual tasks.[1] Many of the items and components needed for the project existed only on the drawing board at the time.[2]

The project was completed two years ahead of schedule.With 1950′s technology (i.e. pencil and paper) managing it. The complexity involved was almost unheard of at the time.

I find it hard to be convinced that the lack of success seen in most projects can be attributed to complexity, especially as most of the dev teams working on corporate Java (or C#, or whatever)  projects are probably working on problems that have already been solved in a different guise, or that need very little in the way of inspired or creative thinking. The hard mathematical bits are already done. The reason for most projects seem to be “lets reinvent $FOO in a different language/platform/design”.

Why then are project managers unable to accurately predict where the project would be after $X months? Could it be the lack of rigour, in that it’s hard to be mathematically rigorous when you are simply listing the activities with thumb-sucked guesses in a spreadsheet, without weighing each activity with a risk? Perhaps it’s because a technical meeting of 12 people is almost always going to result in 2 people talking at any given time and 10 not listening (‘cos the current conversation has no effect on them, nor should it).

Could it be that PM’s have almost no background in statistical methods, leaving them much more vulnerable to getting blind-sided by confirmation bias or misjudging statistical significance as statistical noise?

However, my singular experience with professional software development for the previous 12 years has put me in touch with numerous SW-dev PM’s, at many different companies, and none of them employed any of the methods or techniques used and created for the development of the Polaris Missile. Many of them were not even aware of it, having a more modern certification (PM’s on the Polaris Missile project had no PM certification) that presumably works better.


Or maybe I’m simply wrong, and development in Java or C# really is much more complicated than the advanced calculus and materials engineering needed to build a rocket.

[1] Production and Operations Management, Khanna, PHI Learning Pvt. Ltd., 2007

Harvard University Press, 1972