TestStatistic.cpp

Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 2012 Heiko Strathmann
00008  */
00009 
00010 #include <shogun/statistics/TestStatistic.h>
00011 #include <shogun/base/Parameter.h>
00012 
00013 using namespace shogun;
00014 
00015 CTestStatistic::CTestStatistic() : CSGObject()
00016 {
00017     init();
00018 }
00019 
00020 CTestStatistic::~CTestStatistic()
00021 {
00022 
00023 }
00024 
00025 void CTestStatistic::init()
00026 {
00027     SG_ADD(&m_bootstrap_iterations, "bootstrap_iterations",
00028             "Number of iterations for bootstrapping", MS_NOT_AVAILABLE);
00029     SG_ADD((machine_int_t*)&m_null_approximation_method,
00030             "null_approximation_method",
00031             "Method for approximating null distribution",
00032             MS_NOT_AVAILABLE);
00033 
00034     m_bootstrap_iterations=250;
00035     m_null_approximation_method=BOOTSTRAP;
00036 }
00037 
00038 void CTestStatistic::set_null_approximation_method(
00039         ENullApproximationMethod null_approximation_method)
00040 {
00041     m_null_approximation_method=null_approximation_method;
00042 }
00043 
00044 void CTestStatistic::set_bootstrap_iterations(index_t
00045         bootstrap_iterations)
00046 {
00047     m_bootstrap_iterations=bootstrap_iterations;
00048 }
00049 
00050 float64_t CTestStatistic::perform_test()
00051 {
00052     /* baseline method here is simply to compute statistic and p-value
00053      * separately */
00054     float64_t statistic=compute_statistic();
00055     return compute_p_value(statistic);
00056 }
00057 
00058 bool CTestStatistic::perform_test(float64_t alpha)
00059 {
00060     float64_t p_value=perform_test();
00061     return p_value<alpha;
00062 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation