SHOGUN
v2.0.0
|
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 #ifndef __LINEARTIMEMMD_H_ 00011 #define __LINEARTIMEMMD_H_ 00012 00013 #include <shogun/statistics/KernelTwoSampleTestStatistic.h> 00014 #include <shogun/kernel/Kernel.h> 00015 #include <shogun/lib/external/libqp.h> 00016 00017 namespace shogun 00018 { 00019 00020 class CFeatures; 00021 00074 class CLinearTimeMMD: public CKernelTwoSampleTestStatistic 00075 { 00076 public: 00077 CLinearTimeMMD(); 00078 00089 CLinearTimeMMD(CKernel* kernel, CFeatures* p_and_q, index_t q_start); 00090 00102 CLinearTimeMMD(CKernel* kernel, CFeatures* p, CFeatures* q); 00103 00104 virtual ~CLinearTimeMMD(); 00105 00111 virtual float64_t compute_statistic(); 00112 00126 virtual float64_t compute_p_value(float64_t statistic); 00127 00140 virtual float64_t compute_threshold(float64_t alpha); 00141 00149 virtual float64_t compute_variance_estimate(); 00150 00151 #ifdef HAVE_LAPACK 00152 00168 virtual void optimize_kernel_weights(); 00169 00171 void set_opt_max_iterations(index_t opt_max_iterations) 00172 { 00173 m_opt_max_iterations=opt_max_iterations; 00174 } 00175 00177 void set_opt_epsilon(float64_t opt_epsilon) { 00178 m_opt_epsilon=opt_epsilon; 00179 } 00180 00183 void set_opt_low_cut(float64_t opt_low_cut) 00184 { 00185 m_opt_low_cut=opt_low_cut; 00186 } 00187 00190 void set_opt_regularization_eps(float64_t opt_regularization_eps) 00191 { 00192 m_opt_regularization_eps=opt_regularization_eps; 00193 } 00194 00195 #endif //HAVE_LAPACK 00196 00197 inline virtual const char* get_name() const 00198 { 00199 return "LinearTimeMMD"; 00200 } 00201 00202 private: 00203 void init(); 00204 00205 public: 00206 #ifdef HAVE_LAPACK 00207 00208 static const float64_t* get_Q_col(uint32_t i); 00209 00211 static void print_state(libqp_state_T state); 00212 #endif //HAVE_LAPACK 00213 00214 protected: 00216 index_t m_opt_max_iterations; 00217 00219 float64_t m_opt_epsilon; 00220 00222 float64_t m_opt_low_cut; 00223 00225 float64_t m_opt_regularization_eps; 00226 00228 static SGMatrix<float64_t> m_Q; 00229 }; 00230 00231 } 00232 00233 #endif /* __LINEARTIMEMMD_H_ */ 00234