From ec59213b35989faf07c0ae1211641bdf5f7208cf Mon Sep 17 00:00:00 2001 From: Heiko Strathmann Date: Fri, 1 Apr 2016 11:17:04 +0100 Subject: [PATCH] Give the example some love --- .../quadratic_time_mmd.rst | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/doc/cookbook/source/examples/statistical_testing/quadratic_time_mmd.rst b/doc/cookbook/source/examples/statistical_testing/quadratic_time_mmd.rst index a8a827a03b5..9f0b5ee0199 100644 --- a/doc/cookbook/source/examples/statistical_testing/quadratic_time_mmd.rst +++ b/doc/cookbook/source/examples/statistical_testing/quadratic_time_mmd.rst @@ -2,11 +2,17 @@ Quadratic Time MMD ================== -The unbiased statistic is given by +The Quadratic time MMD implements a nonparametric statistical hypothesis test to reject the null hypothesis that to distributions :math:`p` and :math:`q`, only observed via :math:`n` and :math:`m` samples respectively, are the same: .. math:: - \frac{1}{n(n-1)}\sum_{i=1}^n\sum_{j=1}^n k(x_i,x_i) + k(x_j, x_j) - 2k(x_i,x_j). + H_0:p=q. + +The (biased) test statistic is given by + +.. math:: + + \frac{1}{nm}\sum_{i=1}^n\sum_{j=1}^m k(x_i,x_i) + k(x_j, x_j) - 2k(x_i,x_j). See :cite:`gretton2012kernel` for a detailed introduction. @@ -15,24 +21,38 @@ See :cite:`gretton2012kernel` for a detailed introduction. Example ------- -Imagine we have samples from :math:`p` and :math:`p`. We create CDenseFeatures (here 64 bit floats aka RealFeatures)as +Imagine we have samples from :math:`p` and :math:`q`. We create CDenseFeatures (here 64 bit floats aka RealFeatures)as .. sgexample:: quadratic_time_mmd.sg:create_features -We create an instance of :sgclass:`CQuadraticTimeMMD`, passing it data and the kernel to use, a :sgclass:`CGaussianKernel` here. +We create an instance of :sgclass:`CQuadraticTimeMMD`, passing it data the kernel, and the test significance level :math:`\alpha` .. sgexample:: quadratic_time_mmd.sg:create_instance -Computing the statistic is done as +We can select multiple ways to compute the test statistic, see :sgclass:`CQuadraticTimeMMD` for details. Unbiased statistic + +.. sgexample:: quadratic_time_mmd.sg:estimate_mmd_unbiased + +Biased statistic -.. sgexample:: quadratic_time_mmd.sg:estimate_mmd +.. sgexample:: quadratic_time_mmd.sg:estimate_mmd_biased -We can perform the hypothesis test as +There are multiple ways to perform the actual hypothesis test. The permutation version simulates from :math:`H_0` via repeatedly permuting the samples from :math:`p` and :math:`q`: -.. sgexample:: quadratic_time_mmd.sg:perform_test +.. sgexample:: quadratic_time_mmd.sg:perform_test_permutation + +The spectrum version simulates from :math:`H_0` via approximating the Eigenspectrum of the underlying kernel: + +.. sgexample:: quadratic_time_mmd.sg:perform_test_spectrum + +The Gamma version fit a Gamma cumulative distribution function to :math:`H_0` via moment matching: + +.. sgexample:: quadratic_time_mmd.sg:perform_test_gamma ---------- References ---------- .. bibliography:: ../../references.bib :filter: docname in docnames + +:wiki:`Statistical_hypothesis_testing`