38 using namespace shogun;
53 SG_ERROR(
"Only features with equal number of vectors "
54 "are currently possible\n");
65 SG_ERROR(
"Only features with equal number of vectors "
66 "are currently possible\n");
81 void CQuadraticTimeMMD::init()
84 " for spectrum method null-distribution approximation",
87 " Eigenvalues for spectrum method null-distribution approximation",
134 return first+second-third;
172 return first+second-third;
190 SG_ERROR(
"Unknown statistic type!\n");
209 null_samples.
qsort();
213 SG_ERROR(
"Only possible if shogun is compiled with LAPACK enabled\n");
214 #endif // HAVE_LAPACK
235 bool multiple_kernels)
238 if (!multiple_kernels)
247 "multiple kernels specified, but underlying kernel is not of type "
259 CKernel* current=combined->get_kernel(i);
287 null_samples.
qsort();
290 SG_ERROR(
"Only possible if shogun is compiled with LAPACK enabled\n");
291 #endif // HAVE_LAPACK
320 "(%d, %d): No features set and no custom kernel in use!\n",
321 num_samples, num_eigenvalues);
330 SG_ERROR(
"Currently, only equal sample sizes are supported\n");
334 SG_ERROR(
"Number of samples has to be at least 2, "
335 "better in the hundreds");
338 if (num_eigenvalues>2*
m_m-1)
339 SG_ERROR(
"Number of Eigenvalues too large\n");
341 if (num_eigenvalues<1)
342 SG_ERROR(
"Number of Eigenvalues too small\n");
348 "to be BIASED. Please ensure that! To get rid of warning,"
349 "call %s::set_statistic_type(BIASED)\n",
get_name());
367 for (
index_t i=0; i<num_eigenvalues; ++i)
369 1.0/2/
m_m*eigenvalues[eigenvalues.
vlen-1-i]);
373 for (
index_t i=0; i<num_samples; ++i)
385 #endif // HAVE_LAPACK
391 "No features set and no custom kernel in use!\n");
400 SG_ERROR(
"Currently, only equal sample sizes are supported\n");
406 "to be BIASED. Please ensure that! To get rid of warning,"
407 "call %s::set_statistic_type(BIASED)\n",
get_name());
426 mean_mmd=2.0/m_m*(1.0-1.0/m_m*mean_mmd);
437 if (i==j || m_m+i==j || m_m+j==i)
447 var_mmd*=2.0/m_m/(m_m-1)*1.0/m_m/(m_m-1);
461 num_samples_spectrum)
467 index_t num_eigenvalues_spectrum)
virtual bool init(CFeatures *lhs, CFeatures *rhs)
virtual float64_t compute_threshold(float64_t alpha)
index_t find_position_to_insert(T element)
virtual float64_t compute_p_value(float64_t statistic)
index_t m_num_samples_spectrum
EQuadraticMMDType m_statistic_type
virtual const char * get_name() const
virtual ~CQuadraticTimeMMD()
The Custom Kernel allows for custom user provided kernel matrices.
virtual float64_t compute_statistic()
void set_statistic_type(EQuadraticMMDType statistic_type)
SGVector< float64_t > fit_null_gamma()
virtual int32_t get_num_vectors() const =0
static float64_t randn_double()
index_t m_num_eigenvalues_spectrum
float64_t kernel(int32_t idx_a, int32_t idx_b)
Kernel two sample test base class. Provides an interface for performing a two-sample test using a ker...
static float64_t gamma_cdf(float64_t x, float64_t a, float64_t b)
SGMatrix< float64_t > get_kernel_matrix()
static float64_t floor(float64_t d)
SGVector< float64_t > sample_null_spectrum(index_t num_samples, index_t num_eigenvalues)
void set_num_eigenvalues_spectrum(index_t num_eigenvalues_spectrum)
static SGVector< float64_t > compute_eigenvectors(SGMatrix< float64_t > matrix)
The Combined kernel is used to combine a number of kernels into a single CombinedKernel object by lin...
virtual float64_t compute_unbiased_statistic()
virtual int32_t get_num_vec_rhs()
void set_num_samples_sepctrum(index_t num_samples_spectrum)
virtual float64_t compute_p_value(float64_t statistic)
virtual EKernelType get_kernel_type()=0
The class Features is the base class of all feature objects.
virtual float64_t compute_biased_statistic()
ENullApproximationMethod m_null_approximation_method
static float64_t inverse_gamma_cdf(float64_t p, float64_t a, float64_t b)
virtual float64_t compute_threshold(float64_t alpha)
static int32_t pow(bool x, int32_t n)
static T abs(T a)
return the absolute value of a number