I want to show a line graph with rolling std over the sum of values for an interval of dates.
The code for the generation of the crossfilter/reductio object is :
myCrossfilter = crossfilter(data);
function getRunningDates(numDays) {
return function getDates(d) {
var s = d.ValueDate;
var e = new Date(s);
e.setDate(e.getDate() + numDays);
a = [];
while (s < e) {
a.push(s);
s = new Date(s.setDate(
s.getDate() + 1
))
}
return a;
}
}
var dim1 = myCrossfilter.dimension(getRunningDates(20), true);
var dim2 = myCrossfilter.dimension(dc.pluck("ValueDate"));
var group1 = dim1.group();
var group2 = dim2.group();
var reducerRolling = reductio()
.std("value");
reducerRolling(group1);
var reducer = reductio()
.sum("value")
reducer(group2);
I have put everything into a jsFiddle to show what I mean (unrelated question : I do not understand how the dates on the graphs can go beyond my dateToInit
variable defined in the fiddle).
I would like the bottom graph to be a rolling std
of the values in the top graphs. What ends up happening is that the std
calculation in bottom graph does not do the sum
aggregation first (which makes sense I understand that).
Is there a way to use a group as the dimension for another group ? If not, how would one achieve what I am trying to do ?
Math.sqrt(d.count)
(the square root of the sample size). I'm not sure about getting to the standard deviation of the sum, but I'm sure it's derivable. It should be proportional to the standard deviation of the mean, I would think. – Infinityt
I want to show the standard deviation of the[t-20,t]
interval where the values in the interval are the sums of the values for each day (subject to filtering etc). – NativityMath.random()
which is nice I guess but not that useful for my purposes :) – Nativity