Advertisement
Lawnknome

std div

Apr 19th, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. double std_div(vector<int>& vec, double mean)
  2. {
  3.     vector<double> holder;
  4.     double holder_sum;
  5.     double holder_div;
  6.     double standard_div;
  7.  
  8.     //squares the value minus the mean
  9.     for(int x=0; x < vec.size(); x++)
  10.     {
  11.         holder[x] = pow((vec[x] - mean), 2);
  12.         cout << holder[x] << endl;
  13.     }  
  14.  
  15.     //sum of new vector
  16.     for(int x=0; x < holder.size(); x++)
  17.     {
  18.         holder_sum += holder[x];
  19.     }
  20.  
  21.     holder_div = holder_sum/holder.size();
  22.     standard_div = sqrt(holder_div);
  23.  
  24.     return standard_div;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement