4 ms·
Wasn't immediately clear to me why the derivative comes into play, but let me see if I understand the gist of it. I think this is something interesting I haven'
by floatrock 6y ago
Wasn't immediately clear to me why the derivative comes into play, but let me see if I understand the gist of it. I think this is something interesting I haven't thought about in dataviz before...
So in a traditional 2D heatmap, we discretize the space into squares or bins, then color the bin "proportional" to the number of points that fall inside the bin.
If we're making a 2D heatmap of a timeseries, though, we don't really want to count up the discrete points that make up the timeseries because our binning may not line up with our timeseries sampling frequency. Especially not if we want a very high-resolution heatmap, where each bin is sized to be 1 pixel.
So the solution isn't to count the number of points (from the timeseries data series) in each bin, but rather to count the number of lines that get projected/drawn into each bin (pixel).
But we need to go a step further... if we think of each bin as a hypothetical square, the shortest line through a square is a vertical or horizontal line. And the longest line through a square is a diagonal line. So if we want to represent "how much" of the line goes through a square, we need to measure its slope. Hence, derivative.
So by 2D heatmapping lines instead of points, we're not just counting how many lines fall into each bin, but we also need to weigh each bin-line occurrence by it's arc length, which we use the derivative as a proxy for.
Neat! (I think...)
- yurivish 6y agoI like to think about it from the perspective of continuous time, which is approximated by having #bins = #pixels. The approach relies on having fine-grained bins, since they make error arising from the relationship between binning and the sampling frequency much less significant. Imagine a point moving along the curve, depositing a constant amount of density/ink onto the canvas per unit of time. When the point is moving quickly it deposits less density, and when the point is moving slowly then it deposits more, since the density deposited per time unit is constant and the point traverses less space when it moves slowly. You can think of each vertical strip of bins as representing a unit of time. The discrete approximation to arc-length normalization means, for each time series, making sure that it contributes a single unit of density per vertical strip: if a curve goes through one bin in that strip, then that bin has its density increased by 1. If it goes through 3 bins, then the density in each is increased by 1/3.
- floatrock 6y agoAh, so the quick explanation is how many bins per unit time does the line hit (how many pixels in a vertical stack). If the line is horizontal and hits one bin, then it should have a weight of 1. If it's steep and hits 3 or 5 bins, then the weight should be 1/3 or 1/5 for each bin-pixel. That makes sense. Thanks!