diff options
author | astrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675> | 2009-12-17 13:35:02 +0000 |
---|---|---|
committer | astrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675> | 2009-12-17 13:35:02 +0000 |
commit | eeafd6e502bc60da664de3cf0eb9251f349df228 (patch) | |
tree | 42282436277a2ced2afc899e1d95d08dd50262da /test/test_fitter.cpp | |
parent | 0f296dc20152cb3f442fc3abcbf369e4ece4164d (diff) | |
download | opt-utilities-eeafd6e502bc60da664de3cf0eb9251f349df228.tar.bz2 |
git-svn-id: file:///home/svn/opt_utilities@102 ed2142bd-67ad-457f-ba7c-d818d4011675
Diffstat (limited to 'test/test_fitter.cpp')
-rw-r--r-- | test/test_fitter.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/test_fitter.cpp b/test/test_fitter.cpp new file mode 100644 index 0000000..5e5b139 --- /dev/null +++ b/test/test_fitter.cpp @@ -0,0 +1,39 @@ +#include <core/fitter.hpp> +#include <methods/powell/powell_method.hpp> +#include <statistics/chisq.hpp> +#include <models/nbeta1d.hpp> +#include <data_sets/default_data_set.hpp> +#include <misc/data_loaders.hpp> +#include <core/freeze_param.hpp> +#include <iostream> +#include <string> +#include <fstream> +#include <vector> + +using namespace std; +using namespace opt_utilities; + + +int main(int argc,char* argv[]) +{ + if(argc!=2) + { + cerr<<"Usage:"<<argv[0]<<" <data file>"<<endl; + return -1; + } + fitter<double,double,vector<double>,double,std::string> f; + f.set_model(nbeta1d<double>()); + f.set_opt_method(powell_method<double,vector<double> >()); + f.set_statistic(chisq<double,double,vector<double>,double,std::string>()); + dl_x_xe_y_ye<double,double> dl; + ifstream ifs(argv[1]); + dl.load_from(ifs); + f.load_data(dl.get_data_set()); + f.set_param_modifier(freeze<double,double,vector<double>,string>("bkg")); + f.set_param_value("bkg",0); + f.fit(); + for(int i=0;i<f.get_num_params();++i) + { + cout<<f.get_param_info(i).get_name()<<"="<<f.get_param_info(i).get_value()<<endl; + } +} |