Skip to content

Commit

Permalink
some clean ups
Browse files Browse the repository at this point in the history
  • Loading branch information
karlnapf authored and lambday committed Jul 13, 2016
1 parent ced0bba commit a9cbb50
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
Expand Up @@ -16,21 +16,31 @@ 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`.
As the linear time MMD is a streaming statistic, we need to pass it `CStreamingFeatures`.
Here, we use synthetic data generators, but it is possible to construct `CStreamingFeatures` from (large) files.

.. sgexample:: linear_time_mmd.sg:create_features

We create an instance of :sgclass:`CLinearTimeMMD`, passing it data and the kernel to use, a :sgclass:`CGaussianKernel` here.
We create an instance of :sgclass:`CLinearTimeMMD`, passing it data and the kernel to use,

.. sgexample:: linear_time_mmd.sg:create_instance

An important parameter for controlling the efficiency of the linear time MMD is block size of the number of samples that is processed at once. As a guideline, set as large as memory allows.

.. sgexample::linear_time_mmd.sg:set_burst
Computing the statistic is done as

.. sgexample:: linear_time_mmd.sg:estimate_mmd
.. sgexample::linear_time_mmd.sg:estimate_mmd
We can perform the hypothesis test via computing the rejection threshold

.. sgexample::linear_time_mmd.sg:perform_test_threshold
We can perform the hypothesis test as
Alternatively, we can compute the p-value for the above value of the statistic

.. sgexample:: linear_time_mmd.sg:perform_test
.. sgexample::linear_time_mmd.sg:perform_test_p_value
----------
References
Expand Down
12 changes: 10 additions & 2 deletions examples/meta/src/statistical_testing/linear_time_mmd.sg
Expand Up @@ -13,12 +13,20 @@ mmd.set_num_samples_p(100)
mmd.set_num_samples_q(100)
#![create_instance]

#![set_burst]
mmd.set_num_blocks_per_burst(1000)
#![set_burst]

#![estimate_mmd]
Real statistic = mmd.compute_statistic()
#![estimate_mmd]

#![perform_test]
#![perform_test_threshold]
Real alpha = 0.05
Real threshold = mmd.compute_threshold(alpha)
#![perform_test_threshold]

#![perform_test_p_value]
Real p_value = mmd.compute_p_value(statistic)
#![perform_test]
#![perform_test_p_value]

0 comments on commit a9cbb50

Please sign in to comment.