Subversion Repositories gelsvn

Rev

Rev 2 | Rev 102 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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