32 SG_ERROR(
"CQuadraticTimeMMD: Only features with equal number of vectors "
33 "are currently possible\n");
44 SG_ERROR(
"CQuadraticTimeMMD: Only features with equal number of vectors "
45 "are currently possible\n");
60 void CQuadraticTimeMMD::init()
63 " for spectrum method null-distribution approximation",
66 " Eigenvalues for spectrum method null-distribution approximation",
113 return first+second-third;
151 return first+second-third;
169 SG_ERROR(
"CQuadraticTimeMMD::compute_statistic(): Unknown statistic "
189 null_samples.
qsort();
193 SG_ERROR(
"CQuadraticTimeMMD::compute_p_value(): Only possible if "
194 "shogun is compiled with LAPACK enabled\n");
195 #endif // HAVE_LAPACK
216 bool multiple_kernels)
219 if (!multiple_kernels)
228 "%s::compute_statistic: multiple kernels specified,"
229 "but underlying kernel is not of type K_COMBINED\n",
get_name());
240 CKernel* current=combined->get_kernel(i);
268 null_samples.
qsort();
271 SG_ERROR(
"CQuadraticTimeMMD::compute_threshold(): Only possible if "
272 "shogun is compiled with LAPACK enabled\n");
273 #endif // HAVE_LAPACK
299 REQUIRE(
m_kernel,
"%s::sample_null_spectrum(%d, %d): No kernel set!\n",
300 get_name(), num_samples, num_eigenvalues);
302 "%s::sample_null_spectrum(%d, %d): No features set and no custom "
303 "kernel in use!\n",
get_name(), num_samples, num_eigenvalues);
313 SG_ERROR(
"%s::sample_null_spectrum(): Currently, only equal "
314 "sample sizes are supported\n",
get_name());
319 SG_ERROR(
"%s::sample_null_spectrum(): Number of samples has to be at"
320 " least 2, better in the hundreds",
get_name());
323 if (num_eigenvalues>2*
m_m-1)
325 SG_ERROR(
"%s::sample_null_spectrum(): Number of Eigenvalues too large\n",
329 if (num_eigenvalues<1)
331 SG_ERROR(
"%s::sample_null_spectrum(): Number of Eigenvalues too small\n",
338 SG_WARNING(
"%s::sample_null_spectrum(): Note: provided statistic has "
339 "to be BIASED. Please ensure that! To get rid of warning,"
340 "call %s::set_statistic_type(BIASED)\n",
get_name(),
359 for (
index_t i=0; i<num_eigenvalues; ++i)
361 1.0/2/
m_m*eigenvalues[eigenvalues.
vlen-1-i]);
365 for (
index_t i=0; i<num_samples; ++i)
377 #endif // HAVE_LAPACK
383 "%s::fit_null_gamma(): No features set and no custom kernel in"
394 SG_ERROR(
"%s::compute_p_value_gamma(): Currently, only equal "
395 "sample sizes are supported\n",
get_name());
401 SG_WARNING(
"%s::compute_p_value(): Note: provided statistic has "
402 "to be BIASED. Please ensure that! To get rid of warning,"
403 "call %s::set_statistic_type(BIASED)\n",
get_name(),
423 mean_mmd=2.0/m_m*(1.0-1.0/m_m*mean_mmd);
434 if (i==j || m_m+i==j || m_m+j==i)
444 var_mmd*=2.0/m_m/(m_m-1)*1.0/m_m/(m_m-1);
458 num_samples_spectrum)
464 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)
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)
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)
all of classes and functions are contained in the shogun namespace
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: .
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()
static float64_t inverse_gamma_cdf(float64_t p, float64_t a, float64_t b)
ENullApproximationMethod m_null_approximation_method
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