Skip to content

Instantly share code, notes, and snippets.

@karlnapf
Created March 29, 2016 20:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save karlnapf/b6746cf5a5dff068438b5fc33d493964 to your computer and use it in GitHub Desktop.
CSVFile f_features_p("../../data/two_sample_test_gaussian.dat")
CSVFile f_features_q("../../data/two_sample_test_laplace.dat")
#![create_features]
RealFeatures features_p(f_features_p)
RealFeatures features_q(f_features_q)
#![create_features]
#![create_instance]
QuadraticTimeMMD mmd()
GaussianKernel kernel()
mmd.set_kernel(kernel)
mmd.set_p(features_p)
mmd.set_q(features_q)
Real alpha = 0.05
#![create_instance]
#![estimate_mmd_unbiased]
mmd.set_statistic_type(enum UNBIASED_FULL)
Real statistic_unbiased = mmd.compute_statistic()
#![estimate_mmd_unbiased]
#![estimate_mmd_biased]
mmd.set_statistic_type(enum BIASED_FULL)
Real statistic_biased = mmd.compute_statistic()
#![estimate_mmd_biased]
#![perform_test_permutation]
mmd.set_null_approximation_method(enum PERMUTATION)
mmd.set_num_null_samples(200)
Real threshold_permutation = mmd.compute_threshold(alpha)
Real p_value_permutation = mmd.compute_p_value(statistic)
Real h0_rejected_permutation = mmd.perform_test(alpha)
#![perform_test_permutation]
#![perform_test_spectrum]
mmd.set_null_approximation_method(enum MMD2_SPECTRUM)
mmd.set_num_null_samples(200)
Real threshold_spectrum = mmd.compute_threshold(alpha)
Real p_value_spectrum = mmd.compute_p_value(statistic)
Real h0_rejected_spectrum = mmd.perform_test(alpha)
#![perform_test_spectrum]
#![perform_test_gamma]
mmd.set_null_approximation_method(enum MMD2_GAMMA)
Real threshold_gamma = mmd.compute_threshold(alpha)
Real p_value_gamma = mmd.compute_p_value(statistic)
Real h0_rejected_gamma = mmd.perform_test(alpha)
#![perform_test_gamma]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment