Skip to content

Commit

Permalink
some initial work on Gram-Eigen-Spectrum based Threshold for MMD^2
Browse files Browse the repository at this point in the history
  • Loading branch information
karlnapf committed Jun 3, 2012
1 parent 9b380e8 commit 4343cf8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/shogun/statistics/QuadraticTimeMMD.cpp
Expand Up @@ -106,3 +106,31 @@ float64_t CQuadraticTimeMMD::compute_p_value(float64_t statistic)
return result;
}

SGVector<float64_t> CQuadraticTimeMMD::sample_null_spectrum(index_t num_samples)
{
SGVector<float64_t> null_samples(num_samples);

/* compute kernel matrix for XX, YY, XY */

/* imaginary matrix Kz=[K KL; KL' L] (MATLAB notation) */

/* centering matrix */

/* centering of matrix Kz=H*Kz*H */

/* compute eigenvalues */
/*kEigs = eigs(Kz,params.numEigs); %note: this retains only largest magnitude eigenvalues
%empirical eigenvalues scaled by 1/2/m: see p. 2 Shawe-Tayor
%et al. (2005)
kEigs = 1/2/m * abs(kEigs);
numEigs = length(kEigs); */

/* finally, sample from null distribution */
for (index_t i=0; i<num_samples; ++i)
{
/* 2*sum(kEigs.*(randn(length(kEigs),1)).^2); */
null_samples[i]=0;
}

return null_samples;
}
3 changes: 3 additions & 0 deletions src/shogun/statistics/QuadraticTimeMMD.h
Expand Up @@ -34,6 +34,9 @@ class CQuadraticTimeMMD : public CKernelTwoSampleTestStatistic
return "QuadraticTimeMMD";
};

protected:
SGVector<float64_t> sample_null_spectrum(index_t num_samples);

private:
void init();
};
Expand Down

0 comments on commit 4343cf8

Please sign in to comment.