Benford’s Law analysis of the 2013 Venezuelan Presidential elections

Benford’s Law describes the frequency distribution of digits in many natural sources of data and shows that such distributions are counter-intuitively not uniform. For example, Benford’s Law for the first digit states that the number “1” appears as the first (leading) digit about 30% of the time, the number “2” leads about 17% of the time, and so on. Benford’s Law has been generalized for all digits, not only the leading one. This post considers Benford’s Law for the first digit (1BL) and second digit (2BL).

We took the vote counts for each candidate on the Venezuelan Presidential elections of 2013 (and 2012) and compared the frequency of their first and second digits against the predicted frequencies according to 1BL and 2BL. The vote counts were aggregated at different hierarchical levels: state (24 samples), municipality (335), parish (1,135), voting center (13,683), and voting table (39,018).

 benford_1st_all_table

At the table level, it is clear that none of the candidates’ sample vote counts follow the predicted frequencies. A possible explanation for this result lies on the table sizes being too small (as measured by registered voters) and therefore constraining the data samples. Benford’s Law can only apply to data sets where the sample space spans many orders of magnitude [?]. The voting table sizes in our data range from 26 to 603, with their size heavily skewed towards the upper limit of 600 (90% are between 300 and 600; 65% are between 500 and 600). Consequently, vote counts for either candidate lie in a similarly “small” range. In fact, vote counts for each candidate are normally distributed with a mean of ~200, with about about 80% of them lying between 100 and 300.

Size is not a limiting factor when votes are aggregated at the center or parish level though. For these levels of aggregation, we see the sample data follow 1BL closely.

benford_1st_all_centerbenford_1st_all_parish

We performed the same analysis with respect to the second digit. Again, we see that center-level data follows the expected distribution closely, while table-level data does not.

WordPress serves 404s after changing permalink structure

Problem
You decide to change your Permalink structure on WordPress. After you do, all your posts stop serving and return 404 errors, both at the new and old URLs. If you change your Permalink structure back to what it was before, your posts start serving again.

Solution
There are a couple things you should check:

1. Make sure your WordPress directory is writeable.
The directory were you installed WordPress should be writeable by WordPress. Typically, WordPress runs under the “www-data” user. You can “chown -R www-data $wp-home” to make “www-data” the owner of the directory. A possibly better solution is to make a new group, set the group owner of the directory to such group, and add www-data to the group. Whatever you do, make sure www-data (or whatever user WordPress runs as) has write access to the dir.

2. Make sure mod_rewrite is enabled on your Apache installation.
There’s a pretty good set of steps to follow to enable mod_rewrite here. In summary:

  • Check that you have mod_rewrite. There should be a rewrite.load file under $apache_home/mods-available. Apache is usually installed under /etc/apache2. If it’s not there, you might want to reinstall Apache httpd.
  • Enable mod_rewrite. “a2enmod rewrite” should do the trick (you may have to run it with sudo).
  • Allow overriding. Edit your default Apache config at /etc/apache2/sites-available/default. Find the text:
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
    and change it to
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order allow,deny
    allow from all
  • Restart apache. You can do so with “sudo service apache2 restart”

After you’ve made sure of those two things, try setting your Permalink structure through WordPress again.

Hope that works! Let me know in the comments if it did or did not.