The Artima Developer Community
Sponsored Link

PHP Buzz Forum
Election Reflection 2e

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Chris Shiflett

Posts: 124
Nickname: shiflett
Registered: Sep, 2004

Chris Shiflett is a PHP security specialist and creative thinker.
Election Reflection 2e Posted: Nov 12, 2004 4:39 AM
Reply to this message Reply

This post originated from an RSS feed registered with PHP Buzz by Chris Shiflett.
Original Post: Election Reflection 2e
Feed Title: Chris Shiflett's Blog
Feed URL: http://www.feedburner.com/fb/static/error.html
Feed Description: Author, Consultant, Programmer, Speaker, Trainer
Latest PHP Buzz Posts
Latest PHP Buzz Posts by Chris Shiflett
Latest Posts From Chris Shiflett's Blog

Advertisement
4a84

This is a nonpartisan collection of some of my thoughts about the recent election of the President of the United States. Discussing politics is considered taboo, but there are two issues that I think are huge.

  1. Why must America treat elections like sporting events? The reason that discussing politics is considered taboo is that most people have chosen a team to cheer for (Republican or Democrat), and they can't rationally discuss anything that doesn't favor their team. Most people don't even seem to care who the players are.

    This is hurting America.

    We have freedoms that allow us to question our leaders and to hold them accountable for their actions, but our tendency to consider every topic either for our against our team of choice guarantees that we effectively squelch our own voice. In short, we're squandering our own freedoms. If you want to be heard, you have to respect other people's right to be heard.

  2. Why is our process for tallying votes so fundamentally flawed, and why is this accepted? The legitimacy of this election is in question. The problems with the Diebold electronic voting machines are no secret (they've been discussed on Slashdot more times than I can remember), and there is very strong evidence to suggest that voter fraud involving these machines changed the results of the 2000 election. Yet, we let the same thing happen again. If smart people learn from other people's mistakes, average people learn from their own mistakes, and stupid people never learn, which are we?

    The top two concerns regarding the Diebold machines are that they provide no paper trail (or any other means of auditing the results), and they have known software flaws. Without any way to verify the results, there is no way to ease concerns about voter fraud in this election. With the exit polls indicating strong wins for Kerry in Florida and Ohio, the CEO of Diebold "committed to helping Ohio deliver its electoral votes to the president," the media suspiciously altering the exit polls to reflect the actual results, and the evidence of fraud from the previous election, it's easy to see why people are concerned. I don't blame them. We deserve a transparent voting and tallying process, and we deserve to have confidence in the credibility of any Presidential election. Anything less is unacceptable.


Important issues aside, I have decided to have a little bit of fun with election data to determine who the smart people vote for. Note that this is all in good fun and should not be considered to mean anything important. During an election, a common claim people make is that those with a different choice for President are less intelligent. Determined to get to the bottom of this, I have combined the Education State Rankings with the election results:

<?php 
$x1
= 0;
$y1 = 0;
$x2 = 5;
$y2 = 50;
$gradient = imagecreatefrompng('50x250.png');

foreach (
$ranks as $rank => $state)
{
if (
$state['kerry'] > $state['bush'])
{
$color = imagecolorallocate($gradient, 0, 0, 255);
}
else
{
$color = imagecolorallocate($gradient, 255, 0, 0);
}

imagefilledrectangle($gradient, $x1, $y1, $x2, $y2, $color);
$x1 = $x2;
$x2 += 5;
}

imagepng($gradient);
?>

For the sake of brevity, I have removed the creation of the $ranks array, but the following illustrates how it is constructed, using the smartest state as an example:

<?php 
$ranks
['1']['name'] = 'massachusetts';
$ranks['1']['kerry'] = '62';
$ranks['1']['bush'] = '37';
?>

The resulting image is 50 pixels tall and 250 pixels wide. Each state is represented by a rectangle that is 50 pixels tall and 5 pixels wide. The smarter a state is, the closer it is to the left. The result is a gradient that represents each state's choice for President - blue represents Kerry, and red represents Bush:

electoral.png

With a simple change, I can represent each state with a color that represents the popular vote rather than just the electoral vote:

<?php 
$red
= $state['bush'] * 2.55;
$blue = $state['kerry'] * 2.55;
$color = imagecolorallocate($gradient, $red, 0, $blue);
?>

The resulting image is the same, except that we now have shades of red and blue that represent the polarity of a state's decision:

popular.png

Lastly, let's see what these two gradients look like if we give smarter states a brighter color. I can create a variable called $strength that represents the percentage of 255 that I assign a color, and I'll use the state's rank to calculate this:

<?php 
$strength
= ((102 - (2 * $rank)) / 100);

if (
$state['kerry'] > $state['bush'])
{
$color = imagecolorallocate($gradient, 0, 0, 255 * $strength);
}
else
{
$color = imagecolorallocate($gradient, 255 * $strength, 0, 0);
}
?>

This gives us a weighted electoral vote gradient:

electoral-weighted.png

<?php 
$strength
= ((102 - (2 * $rank)) / 100);
$red = $state['bush'] * 2.55 * $strength;
$blue = $state['kerry'] * 2.55 * $strength;
$color = imagecolorallocate($gradient, $red, 0, $blue);
?>

This gives us a weighted popular vote gradient:

popular-weighted.png

23

Read: Election Reflection 2e

Topic: PHP Magazine 01.05 Preview Previous Topic   Next Topic Topic: Photos from the PHP Conference

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use