On the Fairness of the 2000 and 2016 Presidential Elections

What follows is an interesting thought experiment I thought I’d share. The two major candidates had roughly equal shares of the popular vote. (Red=47.3%, Blue=47.8%). What if the system was modified to take away the 2 bonus “senatorial” electoral votes from each state (and DC)? Well: Red votes => 306-2*30=246; Blue votes => 232-2*21=190. Red still gets the same disproportional amount of electoral votes! (Source: https://en.wikipedia.org/w/index.php?title=Special:CiteThisPage&page=United_States_presidential_election%2C_2016&id=749272989)

Here’s what I mean by same: Define D, the “distortion factor” in favor of the winner, as the ratio of received electoral votes to the number they would have had if electoral votes were perfectly proportional to popular vote. So D[Red, actual]=306/(.473*538)≈1.20 and D[Blue, actual]≈0.90. D[Red, modified]=246/(0.473*436)≈1.19, and D[Blue, modified]=190/(.478*436)≈0.91, which are essentially the same as before. You can also define G, the unfairness gap, as |D[red]-D[blue]|. G[actual]≈0.30, and G[modified]≈0.28, so we did manage to design a slightly more fair electoral tally.

I think that assigning electoral votes by congressional district would probably barely budge this result. The current House has a 247-188 Red majority, despite the fact that in 2014, Blue had a greater number of popular votes for House seats.

By contrast, in 2000, (the most recent other example of electoral college-popular vote mismatch) Red and Blue had similar proportions of the popular vote (47.9% Red, 48.4% Blue), but with Red only winning 271-266 in the electoral college (one elector abstained, Source: https://en.wikipedia.org/w/index.php?title=Special:CiteThisPage&page=United_States_presidential_election%2C_2000&id=749243397). D[Red, actual]=277/(0.479*538)≈1.07 and D[Blue, actual]=266/(0.484*538)≈1.02. G[actual, 2000]=0.05, a lot less unfair than this year, where G is approximately 0.30. In addition, it was still the case that Red had 30 states, giving 60 “senatorial” electoral votes; likewise Blue had 20 states and DC, just like in 2016. Run the same math as above and you get a Blue 211-222 electoral victory. D[red, modified]=211/(0.479*436)≈1.01 and D[blue, modified]=222/(.484*436)≈1.05. G[modified]≈0.04…so we only slightly reduced unfairness, however by making it unfair in Blue’s favor, and just happening to match up with the popular result.

The difference, of course, is that Red picked up some of the bigger states (by population) in 2016 that belonged to Blue in 2000, while Blue picked up fewer of Red’s big states. While it is clear 2016 was more unfair, as measured by D (distortion) and G (distortion gap, a.k.a., unfairness gap), the electoral college result is completely robust due to Red’s capturing of majority of the right states. Notwithstanding any concerns you may have about the particular Red candidate this year, if you accept the electoral college at all, I would say that Red’s victory this year is robust and legitimate.


Debug an Ubuntu/Debian Tomcat User Instance

tomcatI sometimes work on web application code that I test by deploying into a Tomcat servlet container. I develop on Ubuntu-based systems, and like to use the tomcat7-user (and/or tomcat8-user) package for testing. I believe this package is also available on Debian systems.

$ sudo apt-get install tomcat7-user

Once installed, a new command is available for creating local Tomcat instances. It saves me from dealing with a globally configured Tomcat server on my system:

$ tomcat7-create-instance my-tomcat
$ cd my-tomcat/bin
$ ls
setenv.sh  shutdown.sh  startup.sh
$ cat
export CATALINA_BASE="/home/dale/my-tomcat"
echo "Tomcat started"

Of course, the CATALINA_BASE value in your script will be slightly different. Sometimes I want the ability to connect an interactive debugger to my application’s running server-side code. The provisioned startup script doesn’t provide an easy way to enable JPDA so that I can do this. Let’s create a script that will:

$ cp startup.sh debug.sh

Use your favorite editor to modify debug.sh so it looks as follows:

export CATALINA_BASE="/home/dale/my-tomcat"
/usr/share/tomcat7/bin/catalina.sh jpda start 
echo "Tomcat started in debug mode" 

I use Eclipse as my development environment. If you do, too, then you can follow the useful guide at http://blogs.mulesoft.org/debugging-your-tomcat-webapp-with-eclipse/ to connect the interactive debugger to your application.

Recursively find all Symbolic Links with PowerShell

logo-horizontalI just started using SyncThing, and have found it to be a powerful way to keep the files on my various personal computers in sync. I like this solution. I sync on my own private network, avoiding privacy-risking cloud services. I discovered fairly quickly that SyncThing will give warning messages about any symbolic links it encounters, letting you know it won’t try to sync those. In my case, this was shortcut folders like My Videos and My Music in my ~/Documents folder.

powershellThis PowerShell script will let you discover any such symbolic links recursively under a given folder:

if (-not (Test-Path $Path -PathType 'Container'))
  throw "$($Path) is not a valid folder"
$Current=Get-Item .
function Test-ReparsePoint($File) {
  if ([bool]($File.Attributes -band [IO.FileAttributes]::ReparsePoint)) {
  } else {
cd $Path
# Recurse through all files and folders, suppressing error messages.
# Return any file/folder that is actually a symbolic link.
ls -Force -Recurse -ErrorAction SilentlyContinue | ? { Test-ReparsePoint($_) }
cd $Current

The function in this script was derived by from the answer given by Keith Hill at https://stackoverflow.com/questions/817794/find-out-whether-a-file-is-a-symbolic-link-in-powershell. If you save the above script as ~/scripts/FindSymLinks.ps1, here is what a sample session looks like:

PS C:\Users\Dad\scripts> .\FindSymLinks.ps1 ..\Documents
    Directory: C:\Users\Dad\Documents
Mode               LastWriteTime     Length Name
----               -------------     ------ ----
d--hs       10/24/2009   2:09 PM           My Music
d--hs       10/24/2009   2:09 PM           My Pictures
d--hs       10/24/2009   2:09 PM           My Videos

I’m Making My PhD Thesis Available Online

GitHub-Mark-120px-plusOver 10 years ago, I defended my PhD thesis. Due to my moving to another state shortly thereafter, possibly combined with bureaucratic confusion at my alma mater, I never received bound copies of my dissertation. I have also lost any electronic copies I may have once had in the intervening time. Recently, though, my employer started subscribing to a dissertation service, and I was able to download a scanned version of my dissertation.

tumblr_lgabq4NUsR1qb1aw7o1_500Since I had the foresight to apply an open access license to my document, I am creating a web site on GitHub which will be an electronically accessible version of my thesis document. I also have some data backup disks lying around, and intend to upload that data as supplemental material. I have a large family, and not much spare time, but I am making slow progress. The front matter is complete and the first chapter is almost complete. The site is here:
Particle Decay Branching Ratios for States of Astrophysical Importance in 19Ne

Automatically Delete TEMP Folder in Windows (no installs required)

When I use Linux, I love that anything I place in /tmp will be wiped when I shut the system down. Windows, out of the box, doesn’t do this for your %TEMP% folder. Google this, and you’ll find many people advising to install one free tool or another. I am very wary of unnecessary installations on my Windows machines. The advice given here at WindowsForum.org requires no installations. It was meant for Windows XP Pro, but I found today that it worked just as well on my Windows 7 Professional system.

Unlike the fixed /tmp location in Linux, Windows determines the value of %TEMP% and create that folder dynamically at every login. Firefox doesn’t seem to accept %TEMP% as a valid value in browser.download.dir on about:config. Therefore, I

  1. keep a sidebar shortcut to %TEMP% in Windows Explorer, and
  2. select “Always ask me where to save files” in the Downloads section of the General tab of the Options dialog.

That way, it is easy for me to select my %TEMP% folder when downloading in Firefox, as well to access it from Windows Explorer.

Trouble installing Flash on Windows? Check your system clock.

When Adobe released their last security updates for Flash, I was unable to install them on one of my Windows PC’s for either Firefox (plugin version) or Internet Explorer (ActiveX version). I scoured the web and Adobe forums, and approached the problem many different ways, even completely removing Flash from my system, and downloading special MSI installer files from Adobe. Always, the same problem. The installation process starts, then goes nowhere. I get a process for the installation in Task Manager taking up about 10 MB of RAM, and 0% of CPU, that never goes away, and never does anything.

I had resigned that I was never going to have Flash on FF or IE on this system again, unless I re-installed Windows. Then the other day, I randomly noticed that the system clock was 5 hours fast. I’m not sure how or when this happened. I don’t pay attention to the clock on this system because it’s a living room television-attached system mostly for entertainment. Anyways, I corrected the time, and decided to try installing Flash again. Both Plugin-based (for Firefox) and ActiveX-based (for IE) installations went perfectly.

For the curious, the version of Windows is Windows 7 Home Premium, 64-bit.