This is a short note on an interactive visualization I have been playing with for exploring the average/mean. It is intended for folks who may be very new to statistics. It is embedded below from this site on googledrive.
Mathematically, there's not much to this, I guess.
However, I (re)learned several things about d3 I hadn't messed with in a while - mainly to do with its slick animation capabilities for handling when data is updated. And the impact of this animation, coupled with the default easing functions, is way out of whack with how much animation there may actually be.
There were a number of conscious decisions here with respect to how the user is allowed to interact with it.
First, there are no text inputs - you can only change things by dragging one of the bars or clicking one of the buttons. Numeric input is an edge case bear, imo, especially on a tablet.
Second, there is a bottom area underneath the bars that allows the user to drag a value down to zero and back up from zero. This is done via small svg rect's that have their css "pointer-events" set to none, so that mouse/touch events pass down to the full rect beneath it.
I wanted to make sure and include the actual equation being used for calculating the average, filled in with the particular values active at the moment. I started down the path of incorporating MathJax for this, but decided that it might not update fast enough, and setting up a pre-rendered template did not seem straightforward (although it might be). So, I just boxed an equation together with some tables. If you mouse over one of the bars, or drag it to change its value, the corresponding entry in the equation is highlighted and updated.
I have tried this on both a Nexus 7 and an iPad. Both seem ok in the (perhaps odd) "Auto Run" mode for this app.
On the Nexus 7, the dragging and subsequent updating on the Nexus is actually usable, although there is some jank with the window sizing sometimes.
On the iPad, the latency in the dragging is irritating. I don't know if there are further optimizations that would work there, short of not updating everything on every drag event d3 is telling me about.
The visualization is redrawn when the screen is resized, and it seems to work pretty well on the desktop.
with window size
I have noticed quirks with the rendering on tablets - I wonder if there are blips in sizing events that result in erratic size information.
I really don't know if this may be useful for someone somewhere trying to get a better feel for the average/mean. I had originally planned to be able to show how one extreme value could "unreasonably sway" the mean, highlighting how its use as a measure of central tendency can be suspect. The results with the small range here were disappointing. I might be missing an easy angle, though.
I do think that there is tremendous potential in education and general insight given the relative ease of creating interactive d3 visualizations underpinned by mathematics/computation limited only by your imagination.
Art, education, mathematics, statistics. I continue to be impressed with javascript.
No comments:
Post a Comment