A simple conciseness improvement would be to inline non-informative variables:
template <typename IT>
E std_dev(IT begin, IT end) {
auto N = std::distance(begin, end);
E variance = std::accumulate(begin, end, E{},
[average=std::accumulate(begin, end, E{}) / N](E init, E value) -> E
{
return init + (value - average)*(value - average);
});
return std::sqrt(variance * 1.0 / (N - 1));
}
average was moved into the lambda capture (C++14(?)) and the lambda itself was passed directly to std::accumulate.