Thursday, December 15, 2016

Heatmaps of Different Keyboard Layouts

Most people use QWERTY as their keyboard layout. I did too, until about one year ago. Over the past year, I’ve tried both Dvorak and Colemak. I’ve gotten to about 60-70 WPM on all three of these layouts, and after that I feel that typing speed doesn’t really matter much anymore—especially if I’m coding and I’m spending most of my time thinking instead of typing. But I still like Dvorak and Colemak better than QWERTY because they are more comfortable. I think I’ll stick with Colemak, since it’s more similar to QWERTY, and I want to be prepared for situations where I may be forced to use a QWERTY keyboard.
I wanted to create some visualizations to make the benefits of Dvorak and Colemak more apparent. Here are some heatmaps I generated in Python using numpy and Pillow. These are based on the frequency of letter usage (data from Wikipedia). Red corresponds to more frequently used areas, and blue corresponds to less frequently used areas.

QWERTY


Colemak

Dvorak


Pretty cool, huh? You can see that clearly, Colemak and Dvorak allow you to stay on the home row (the middle row) far more than QWERTY does. QWERTY just has your fingers going all over the place.

The math behind the heatmaps

I actually generated the pixel data for the heatmaps using my own algorithm, since I thought it would be fun. I don’t actually know how heatmaps are typically generated, but maybe it’s somewhat similar to this. I’ll explain the math I used.
So here’s the information I started with:
  • , the number of keys on the keyboard
  • for , the pixel coordinates of key
  • , the frequency of usage of key (i.e. the proportion of all letters that this letter makes up)
The goal is to assign a number to each point on the plane corresponding to the intensity of that point in the heatmap. One obvious way to go about this would be to go through each from 0 to , and then color the point with intensity —then for any remaining points, color them with intensity 0. However, this would make for a rather boring diagram, since only single hard-to-see pixels would be colored, and most of the diagram would be zeroes. So, I came up with a better way.
I needed a way for keys to color the points closer to them with a higher intensity than points farther away from them. For this, I used something similar to a Gaussian PDF. I used this formula to determine how much key should color point :

To break this down, the term represents the squared distance between the point to color and the key in question. When we multiply by -0.003 (a completely arbitrary constant that I fould worked well) and then exponentiate it, we get a term that peaks at , but then tapers off to 0 uniformly in all directions as it gets farther and farther from . Then we multiply it by , since we want more frequent keys to have more intensity than less frequent keys. I then summed these terms over all to get my final calculation:

This is what my program calculated for every point in the image. It then converted it to an appropriate RGB color, and saved the image as a PNG so that I could see it!
Written with StackEdit.

1 comment:

  1. Paddy Power Casino Map & Directions - Mapyro
    Paddy Power Casino is a Casino in the heart of 순천 출장마사지 Australia. The site 광주광역 출장샵 is located in Pyrmont, Western Australia and offers 양산 출장마사지 an enormous gambling 부천 출장안마 floor for  Rating: 4.1 · 원주 출장안마 ‎1,942 reviews

    ReplyDelete