source: trunk/c++_tools/statistics/NaiveWeighted.cc @ 586

Last change on this file since 586 was 586, checked in by Peter, 15 years ago

closes #23 redesign of regression classes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 618 bytes
Line 
1// $Id: NaiveWeighted.cc 586 2006-06-19 09:56:04Z peter $
2
3#include <c++_tools/statistics/NaiveWeighted.h>
4
5#include <c++_tools/statistics/AveragerWeighted.h>
6#include <c++_tools/statistics/OneDimensional.h>
7#include <c++_tools/gslapi/vector.h>
8
9#include <iostream>
10
11
12namespace theplu {
13namespace statistics {
14namespace regression {
15
16
17  void NaiveWeighted::fit(const gslapi::vector& x,
18                  const gslapi::vector& y,
19                  const gslapi::vector& w)
20  {
21    AveragerWeighted a;
22    for (size_t i=0; i<y.size(); i++)
23      a.add(y(i), w(i));
24    m_=a.mean();
25    m_err_=a.standard_error();
26    s2_=m_err_*m_err_*w.sum(); 
27  }
28
29
30}}} // of namespaces regression, statisitcs and thep
Note: See TracBrowser for help on using the repository browser.