Showing posts with label visualization. Show all posts
Showing posts with label visualization. Show all posts

Sunday, October 11, 2020

Game of Risk Elm Visualization

Building on the previous post... an interactive(ish) Elm visualization of the game's probability trees: 

https://tarokuriyama.com/projects/risk.php


Friday, August 28, 2020

Sudoku Visualization

The Sudoku solver visualization in Elm is done! 

https://tarokuriyama.com/projects/sudoku.php

Writing Elm feels similar to writing Haskell, with a bit of syntax that's more like F# (e.g. the pipeline operators <| and |>). Between the familiar format of Learn You and Elm and the examples in Beginning Elm, it's relatively easy to pick up given a bit of functional programming background.

All of the code for the solver and visualization is on GitHub.








 

Monday, November 25, 2013

Thanksgiving with D3


I've been studying bits and pieces of D3.js for the past few weeks.  Although I've struggled with data binding in the data-driven nature of the framework, the library comes with a large number of interesting features like support for Voronoi diagrams and dozens of geographical projections.

The creator of the library, Mike Bostock, has made a mind-boggling number of examples available on http://bl.ocks.org/, and there's also a text by Scott Murray that O'Reilly makes available for free online.

Since it's almost Thanksgiving, I thought I'd try making some choropleths about turkey production and consumption in the US.  As it turns out, this is fairly straightforward using D3: download some free SVGs of blank maps from Wikimedia Commons; find the relevant US Census and USDA data to create CSV files; and link up the two with a few lines of code.

  • Top = turkey production by state in 2010[1].  Minnesota and North Carolina produce by far the most turkeys, with a combined total of over 2 billion pounds.
  • Bottom = per capita meat consumption by county in 2011[2].  The relative uniformity of the data isn't surprising, but I wouldn't have guessed the pockets of above-average consumption in the Northeast and California (perhaps a positive correlation with income?).  




[2] USDA, Food Environment Atlas Data, 2011.  This was the closest proxy I could find to turkey consumption.  No data available for Alaska and Hawaii.


Saturday, November 16, 2013

Visualizing Algorithms

Bret Victor suggests in his fascinating talk that the current programming paradigm involves "playing computer", insofar as we must envision how a computer will interpret code as we build up more and more complex ideas.  It's clear that most human minds cannot immediately internalize complex ideas -- this is why teaching is about breaking down subjects into digestible modules, often with visual aids.

Although the materials in a class like Tim Roughgarden's Algorithms: Design and Analysis are extremely well presented, I can't help but think that for topics like graph search and dynamic programming, visualizations could be an additional, effective tool for helping students learn.

I tried my hand at creating one such visualization -- the algorithm is for finding the longest palindromic substrings within a given string, e.g. "racecar" within "red hot racecar".  Here's the link.