Subversion Repositories gelsvn

Rev

Rev 2 | Rev 102 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 bj 1
#ifndef __CGLA_STATISTICS_H__
2
#define __CGLA_STATISTICS_H__
3
 
4
#include <vector>
5
 
6
namespace CGLA
7
{
12 jab 8
  template<class VT>
9
    VT mean(const std::vector<VT>& vec)
10
    {
11
      VT v(0);
12
      for(int i=0;i<vec.size();++i)
13
	v += vec[i];
14
      v /= vec.size();
2 bj 15
 
12 jab 16
      return v;
17
    }
2 bj 18
 
19
 
12 jab 20
  /** Function that computes the covariance of a set of points.
21
      This function returns the mean, and, upon completion, the
22
      final argument contains the covariance matrix.
2 bj 23
 
12 jab 24
      This template is instantiated for Vec3f, Vec2f, and Vec4f. */
2 bj 25
 
12 jab 26
  template<class VT, class MT>
27
    VT covariance(const std::vector<VT>& vec, MT& C_out);
2 bj 28
}
29
 
30
 
31
 
32
 
33
#endif