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.

Situation in Venezuela (short version)

Amidst the Boston Marathon bombings, the Texas plant explosion, and the recent Boston/MIT shootings, I bring you some more news to keep you on your toes.

Some of you may have heard about the unrest in Venezuela after this past Sunday’s elections. I wanted to give you a quick summary of what has happened. I’ll save the discussion of why Chavismo has been so destructive to Venezuela for later and stick to the facts now.

Mega quick summary:
(Note: this is a work in progress and I’m still adding references–ignore the empty brackets)

Venezuelan Presidential elections were held on Sunday. The two main candidates were Maduro (Chavez’s chosen successor) and Henrique Capriles (HCR, current governor of Miranda and main opposition leader). The CNE announced results on Sunday night putting Maduro ahead by a narrow margin (235,000 votes) [].

The margin was small enough and there were enough irregularities throughout the elections that HCR decided to call for a full audit of the ballot boxes (Venezuelan votes are electronic, but you get a receipt which you enter in a box). Such audits are abided by the law–law states that anyone has 15 business to file a petition for it []. The CNE had, until last night, chosen to ignore such petitions and declared Maduro as the winner (note that 4 out of 5 of the CNE’s directors are from the same party as Maduro).

People took to the streets in protest on Monday and Tuesday. There were some confrontations and violence: people hitting/shooting other people [], the national guard (GNB) shooting (tear gas and pellets) against civilians [], buildings vandalized and set on fire (party offices from both sides, telecom networks) [], etc. So far at least 8 people have died, hundreds have been injured and detained. There have been clear violations of human rights (e.g. footage of a national guardsman shooting (pellets) at an unresisting civilian) [].

The opposition is demanding an audit/recount. If Maduro had won legitimately, there should be no reason why he would oppose this. The opposition is also reporting over 3,000 documented irregularities that occurred throughout election day. These include instances of assisted vote (where someone looks over your shoulder while you vote) [], illegal proselytism at voting centers, voter intimidation by hordes near centers [], centers illegally closing earlier or later than when they were supposed to, witnesses being expelled from centers (sometimes with death threats), etc. The law states that where these events occur, the votes should be void and recast. The CNE and Maduro had chosen to ignore all these claims (until last night!).

[On a personal note, I ran a quick analysis over the numbers that the CNE had put forth initially and wrote it up on a blog post []. My blog (that I created on Monday just for this) was subsequently blocked by the government-owned ISP. It has been unblocked since yesterday.]

During the week, government workers who voted for HCR started getting fired from their jobs (there have been two documented cases of this–one of which is a recording of a manager openly saying that he’ll fire everyone who voted HCR) [][]. In the National Assembly (the AN, equivalent of Congress), opposition delegates have been denied the right to speak by its president (who is from the same party as Maduro) []. One of the congressmen was physically assaulted–a microphone was thrown at his face [].

Things have been calming down a bit more recently. The opposition continued to push for the audit through legal means, and HCR tried to maintain peace by urging his supporters NOT to go out and protest in the streets (even though some supporters saw this as a sign of weakness). Instead, he urges them to protest from home by banging on pots in what is known as a cacerolazo [].

We got our first victory last night. After an 8-hour discussion with the opposition, the CNE announced that it would conduct an audit of the remaining 46% of the tables (54% are audited by default) throughout the next month. However, they did not specify the terms of the audit (ballot box, voting books, fingerprint scanners, etc.). Nothing was said about what is to be done, if anything, about the remaining reported irregularities. Regardless of the audit, Maduro was sworn in today. Despite all of this, HCR has shown that the all-powerful government that would never give in before, can in fact be pressured into giving in to the people’s demands, at least partially.

My take is that no proof of wrongdoing will come out from the full audit, either because there was no wrongdoing (in the actual vote counting), or because they would’ve had enough time to dot their i’s and cross their t’s by then. The real wrongdoing here has happened before and during the election day: the use of government funds to finance Maduro’s campaign, the unfairness of allowed airtime for candidates (allowing HCR 30-seconds of airtime/day during the campaign while Maduro went on 5+ hour nationwide broadcasts), the freebies handed out to pro-Chavez voters, the voter intimidation through violence and fear of losing your job, and all the other irregularities that I’ve already mentioned.

Nonetheless, I think it is a step forward. I think HCR has gathered even more support throughout these days. The opposition has offered support to those who have been wrongfully arrested or unreasonably fired from their jobs. Maduro has proven to be a weak leader, has been caught outright lying[], has lost hundreds of thousands of supporters, and is simply (IMO) incapable of moving the country forward given the dire state that Chavez left it at (especially now that money will be tight since oil prices are going down). The end is near. My pessimistic prediction is that in 3 years Maduro will be ousted in a recall referendum.

That’s it for the “short” version. Thanks for reading. What really happened is much more nuanced than this overview. I’m working on a longer version that offers more detail and explanations. I’ll update this and FB/G+ when it’s ready.

References:
–to be completed. For the time being, I’m collecting all references here.
[] William Davila assaulted at National Assembly (Spanish).

CNE data discrepancies

(Note: this is a summary of a prior analysis and its update (in Spanish))

Of all the coverage on the Venezuelan presidential elections, it has been surprising that no attention has been paid to the two discrepancies between the results quoted by the National Electoral Council of Venezuela (CNE) during its first press release on the evening of April 14 [1], and its website [2] just a few minutes later.

While the vote counts for each candidate were unchanged, two derived numbers (voter participation rate and book transmission rates) did change after CNE’s initial announcement:

  • On Sunday night’s press release, Tibisay Lucena, president of the CNE, announced per-candidate vote counts (Maduro: 7,505,338; Capriles: 7,270,403; all others: 38,756), a voter participation rate of 78.71%, and transmission rate of 99.12%.

  • Later that evening, the CNE published official numbers on its website. Despite the fact that the per-candidate votes matched those of the press release, the participation and transmission rates had mysteriously changed to 79.84% and 98.58%, respectively.

It is unclear how the rates could have changed while per-candidate votes remained the same. The CNE owes an explanation for these discrepancies.

(I’m working on a full explanation of what each of the CNE released figures mean, to be published shortly).

[1] CNE Press Release, transmitted at 11:15 PM VET.
[2] CNE website screenshot, taken on Monday at 8 AM VET. The screenshot claims the data was last updated at 11:07 PM VET, shortly before the release. The CNE site has since updated its data.


Update a los numeros de Tibisay

Al parecer la pagina del CNE no esta disponibles a conexiones desde el exterior. Un amigo me mando el resumen de los resultados.

Con ellos podemos aclarar las discrepancias que mencione en el post anterior. La conclusion es que, como senialado en el post anterior, Tibisay dio numeros de porcentajes erroneos. El porcentaje de votos nulos tambien fue mas bajo de lo estimado.

Detalles:

Continue reading

Los numeros de Tibisay… son cuestionables

(Nota: este analsis esta hecho sobre los datos que presento Tibisay en la rueda de prensa ayer. No tengo acceso a la pagina del CNE desde el exterior, asi que no he podido ver los numeros oficiales que han publicado, si han actualizado su % de votos nulos, etc.)

Hice un pequenio analisis de los resultados que anuncio Tibisay ayer[1], comparandolos con los resultados del 7 de Octubre (7O) [2]. Encontre una posible discrepancia de 66,000 a 360,000 votos en los resultados anunciados por Tibisay.

La suma de los votos por candidatos es de 14,814,497. El numero estimado de votos validos, acorde a los porcentajes anunciados por Tibisay, es de 14,452,217. Hay un estimado 362,280 votos de diferencia.

Las posibles razones que podrian explicar esta discrepancia:

  • Una baja drastica en el numero de votos nulos en comparacion con el 7O (incluso si los votos nulos bajan del 1,89% en el 7O al 0% ahora, eso solo explica ~300,000 de los votos de discrepancia, dejando ~60,000 sin explicacion).
  • Un incremento en el numero de electores registrados (lo cual seria ilegal). Para que los numeros concuerden, el numero de electores registrados debio haber subido por ~470,000 personas.
  • Tibisay anuncio data erronea, que no concuerda. Si se toman los votos asignados por candidato como la verdad, entonces los porcentajes dados (99.12% escrutinio y 78.71% participacion son erroneos). Si se toman los porcentajes como verdaderos, entonces a los candidatos les asignaron mas votos de la cuenta, sin explicacion.

Como la data esta incompleta, este estudio no puede probar nada, pero si lleva a la luz posible discrepancias que no son despreciables y deben ser investigadas. El CNE tiene que aclarar estas discrepancias. En unos resultados donde 235,000 votos hacen la diferencia, no puede haber un margen de error de 60 a 360 mil votos.

Aca estan los detalles del analisis:

Continue reading