Standard deviation from iterators
Firstly, make it correct.

N is integral, you could make it E so you don't accidentally do integer arithmetic.

N-1 is wrong.

Rename average to mean. 

Don't hardcode E.

You get:

template &lt;typename It, typename E = typename std::iterator_traits&lt;It&gt;::value_type&gt;
E std_dev(It begin, It end){
    E N = std::distance(begin, end);
    E const mean = std::accumulate(begin, end, E()) / N;
    auto sum_term = [mean](E init, E value)-&gt; E { return init + (value - mean)*(value - mean); };
    E variance = std::accumulate(begin, end, E(), sum_term);
    return std::sqrt(variance / N);
}


Slightly stylized, with comparison to Boost Accumulator: 

Live On Coliru

#include &lt;iostream&gt;
#include &lt;iterator&gt;
#include &lt;vector&gt;
#include &lt;algorithm&gt;

#include &lt;boost/accumulators/accumulators.hpp&gt;
#include &lt;boost/accumulators/statistics.hpp&gt;

template &lt;typename It, typename E = typename std::iterator_traits&lt;It&gt;::value_type, typename R = typename std::common_type&lt;double, E&gt;::type&gt;
R std_dev_boost(It begin, It end){
    namespace ba = boost::accumulators;

    ba::accumulator_set&lt;R, ba::stats&lt;ba::tag::variance&gt; &gt; accu;
    std::for_each(begin, end, std::ref(accu));
    return std::sqrt(ba::variance(accu));
}

template &lt;typename It, 
    typename E = typename std::iterator_traits&lt;It&gt;::value_type, 
    typename R = typename std::common_type&lt;double, E&gt;::type&gt;
R std_dev(It b, It e)
{
    R N          = std::distance(b, e);
    R const mean = std::accumulate(b, e, R{}) / N;
    R variance   = std::accumulate(b, e, R{}, [mean](R a, E v)-&gt; R { return a + (v-mean)*(v-mean); });
    return std::sqrt(variance / N);
}

int main(){
    std::vector&lt;int&gt; stuff {35, 34, 36, 39, 35, 35, 35, 35, 35};
    std::cout &lt;&lt; std_dev_boost(stuff.begin(), stuff.end()) &lt;&lt; "\n";
    std::cout &lt;&lt; std_dev      (stuff.begin(), stuff.end()) &lt;&lt; "\n";
}


Prints

1.34256
1.34256