aboutsummaryrefslogtreecommitdiffstats
path: root/mass_profile/fit_direct_beta.cpp
blob: cc1d7c99d5a16ab266f14e53822b778c91687ac8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <iostream>
#include <string>
#include <vector>
#include <statistics/chisq.hpp>
#include <methods/powell/powell_method.hpp>
#include <data_sets/default_data_set.hpp>
#include <misc/data_loaders.hpp>
#include "methods/aga/aga.hpp"
#include <models/beta1d.hpp>
using namespace std;
using namespace opt_utilities;



int main(int argc,char* argv[])
{

  if(argc!=2)
    {
      cerr<<"Usage:"<<argv[0]<<" <sbp data>"<<endl;
      return -1;
    }

  fitter<double,double,vector<double>,double,string> f;
  
  f.set_statistic(chisq<double,double,vector<double>,double,string>());
  f.set_opt_method(powell_method<double,vector<double> >());
  f.set_model(beta1d<double>());
  dl_x_xe_y_ye<double,double> dl;
  ifstream ifs(argv[1]);
  ifs>>dl;
  f.load_data(dl.get_data_set());
  f.fit();
  
  double rmin=f.get_data_set().get_data(0).get_x();
  double rmax=f.get_data_set().get_data(f.get_data_set().size()-1).get_x();
  cout<<"read terr 1 2\nskip single\n";
  for(int i=0;i<f.get_data_set().size();++i)
    {
      cout<<f.get_data_set().get_data(i).get_x()<<"\t"<<
	-abs(f.get_data_set().get_data(i).get_x_lower_err())<<"\t"<<
	abs(f.get_data_set().get_data(i).get_x_upper_err())<<"\t"<<
	f.get_data_set().get_data(i).get_y()<<"\t"<<
	-abs(f.get_data_set().get_data(i).get_y_lower_err())<<"\t"<<
	abs(f.get_data_set().get_data(i).get_y_upper_err())<<endl;

	
    }
  cout<<"no no no\n";

  for(double i=rmin;i<rmax;i+=1)
    {
      cout<<i<<"\t0\t0\t"<<f.eval_model(i,f.get_all_params())<<"\t0\t0"<<endl;
    }

  for(int i=0;i<f.get_num_params();++i)
    {
      cerr<<f.get_param_info(i).get_name()<<"="<<
	f.get_param_info(i).get_value()<<endl;
    }
}