aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsamples/abin9817 -> 0 bytes
-rw-r--r--samples/a.cc36
-rw-r--r--statistics/cstat.hpp18
3 files changed, 8 insertions, 46 deletions
diff --git a/samples/a b/samples/a
deleted file mode 100755
index b8b8e8c..0000000
--- a/samples/a
+++ /dev/null
Binary files differ
diff --git a/samples/a.cc b/samples/a.cc
deleted file mode 100644
index 1cf92df..0000000
--- a/samples/a.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-#include <cmath>
-#include <fstream>
-#include <iostream>
-using namespace std;
-
-double powerlaw(double x)
-{
- return 5*pow(x,-1.1);
-}
-
-double bpl(double x)
-{
- double x_b=5;
- double f_b=10;
- double gamma1=-0.8;
- double gamma2=-1.5;
- if(x<x_b)
- {
- return f_b*pow(x,gamma1)/pow(x_b,gamma1);
- }
- else
- {
- return f_b*pow(x,gamma2)/pow(x_b,gamma2);
- }
-}
-
-
-
-int main()
-{
- double x,y,x1,x2,y1,y2;
- while(cin>>x>>x1>>x2>>y>>y1>>y2)
- {
- cout<<x<<"\t"<<y<<"\t"<<y-y1<<"\t"<<y+y2<<endl;
- }
-}
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)<<",";