aboutsummaryrefslogtreecommitdiffstats
path: root/statistics
diff options
context:
space:
mode:
authorastrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675>2009-08-16 11:32:47 +0000
committerastrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675>2009-08-16 11:32:47 +0000
commit9fcda2d737def25854456a64d4d8c6f24771341f (patch)
tree42995a07161e821f682b39288825a9966fe5ae02 /statistics
parent0b41a876bc104c5791271ca085d2f696462e0fd0 (diff)
downloadopt-utilities-9fcda2d737def25854456a64d4d8c6f24771341f.tar.bz2
git-svn-id: file:///home/svn/opt_utilities@41 ed2142bd-67ad-457f-ba7c-d818d4011675
Diffstat (limited to 'statistics')
-rw-r--r--statistics/cstat.hpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/statistics/cstat.hpp b/statistics/cstat.hpp
index ce8469e..058523d 100644
--- a/statistics/cstat.hpp
+++ b/statistics/cstat.hpp
@@ -7,19 +7,17 @@ using std::cout;using std::endl;
namespace opt_utilities
{
template<typename Ty,typename Tx,typename Tp,typename Ts,typename Tstr>
- class cstat_poisson
+ class cstat
:public statistic<Ty,Tx,Tp,Ts,Tstr>
{
private:
bool verb;
int n;
-
- Ty lnfrac(Ty y)const
- {
- return y*log(y)-y;
- }
-
public:
+ cstat()
+ :verb(true)
+ {}
+
void verbose(bool v)
{
verb=v;
@@ -29,7 +27,7 @@ namespace opt_utilities
statistic<Ty,Tx,Tp,Ts,Tstr>* do_clone()const
{
// return const_cast<statistic<Ty,Tx,Tp>*>(this);
- return new cstat_poisson<Ty,Tx,Tp,Ts,Tstr>(*this);
+ return new cstat<Ty,Tx,Tp,Ts,Tstr>(*this);
}
Ts do_eval(const Tp& p)
@@ -38,7 +36,7 @@ namespace opt_utilities
for(int i=(this->get_data_set()).size()-1;i>=0;--i)
{
Ty model_y=eval_model(this->get_data_set().get_data(i).get_x(),p);
- result+=model_y-this->get_data_set().get_data(i).get_y()*log(model_y)+lnfrac(this->get_data_set().get_data(i).get_y());
+ result-=this->get_data_set().get_data(i).get_y()*std::log(model_y);
}
if(verb)
@@ -46,7 +44,7 @@ namespace opt_utilities
n++;
if(n%10==0)
{
- cout<<result/this->p_fitter->get_dof()<<"\t";
+ cout<<"a:"<<result<<"\t";
for(int i=0;i<get_size(p);++i)
{
cout<<get_element(p,i)<<",";