# Compute the sample standard deviation : inner_product « STL Algorithms Helper « C++

Home
C++
 1 Bitset 2 Class 3 Console 4 Data Structure 5 Data Type 6 Deque 7 Development 8 File 9 Function 10 Generic 11 Language 12 List 13 Map Multimap 14 Overload 15 Pointer 16 Qt 17 Queue Stack 18 Set Multiset 19 STL Algorithms Binary search 20 STL Algorithms Heap 21 STL Algorithms Helper 22 STL Algorithms Iterator 23 STL Algorithms Merge 24 STL Algorithms Min Max 25 STL Algorithms Modifying sequence operations 26 STL Algorithms Non modifying sequence operations 27 STL Algorithms Sorting 28 STL Basics 29 String 30 Valarray 31 Vector
 C++ » STL Algorithms Helper » inner_product Screenshots
Compute the sample standard deviation
 ```   #include  #include  #include  #include  #include  #include  #include  using namespace std; template  void print(T& c){    for( typename T::iterator i = c.begin(); i != c.end(); i++ ){       std::cout << *i << endl;    } } int main( ) {    const float a[] = { 1, 1.3, 1.5};    vector data( a,a + sizeof( a ) / sizeof( a[0] ) );    print( data  );    float mean = accumulate( data.begin(), data.end(), 0.0f )/ data.size();    cout << mean;    vector zero_mean( data );    transform( zero_mean.begin(), zero_mean.end(), zero_mean.begin(),bind2nd( minus(), mean ) );    float deviation = inner_product( zero_mean.begin(),zero_mean.end(), zero_mean.begin(), 0.0f );    deviation = sqrt( deviation / ( data.size() - 1 ) );    cout << deviation; }           ```
Related examples in the same category
 1 Use inner_product to process sum of all products(0 + 1*1 + 2*2 + 3*3 + 4*4 + 5*5 + 6*6) 2 Use inner_product to calculate inner reverse product 3 Use inner_product with inner and outer operation 4 inner_product( ) produces a summation of the product of corresponding elements in two sequences and returns the result.