SHOGUN  v3.0.1
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
MMDKernelSelectionOpt.cpp
浏览该文件的文档.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2012-2013 Heiko Strathmann
8  */
9 
13 
14 using namespace shogun;
15 
18 {
19  init();
20 }
21 
25 {
26  init();
27 
28  /* currently, this method is only developed for the linear time MMD */
29  REQUIRE(dynamic_cast<CLinearTimeMMD*>(mmd), "%s::%s(): Only "
30  "CLinearTimeMMD is currently supported! Provided instance is "
31  "\"%s\"\n", get_name(), get_name(), mmd->get_name());
32 
33  m_lambda=lambda;
34 }
35 
37 {
38 }
39 
41 {
42  /* comnpute mmd on all subkernels using the same data. Note that underlying
43  * kernel was asserted to be a combined one */
46  ((CLinearTimeMMD*)m_mmd)->compute_statistic_and_variance(mmds, vars, true);
47 
48  /* we know that the underlying MMD is linear time version, cast is safe */
49  SGVector<float64_t> measures(mmds.vlen);
50 
51  for (index_t i=0; i<measures.vlen; ++i)
52  measures[i]=mmds[i]/(CMath::sqrt(vars[i])+m_lambda);
53 
54  return measures;
55 }
56 
57 void CMMDKernelSelectionOpt::init()
58 {
59  /* set to a sensible standard value that proved to be useful in
60  * experiments, see NIPS paper */
61  m_lambda=1E-5;
62 }
CKernelTwoSampleTestStatistic * m_mmd
int32_t index_t
Definition: common.h:60
virtual SGVector< float64_t > compute_measures()
#define REQUIRE(x,...)
Definition: SGIO.h:208
Base class for kernel selection for MMD-based two-sample test statistic implementations (e...
double float64_t
Definition: common.h:48
virtual const char * get_name() const =0
Two sample test base class. Provides an interface for performing a two-sample test, i.e. Given samples from two distributions and , the null-hypothesis is: , the alternative hypothesis: .
This class implements the linear time Maximum Mean Statistic as described in [1]. This statistic is i...
Definition: LinearTimeMMD.h:75
static float32_t sqrt(float32_t x)
x^0.5
Definition: Math.h:252
index_t vlen
Definition: SGVector.h:706

SHOGUN Machine Learning Toolbox - Documentation