#include #include // // Written by: // -- // John L. Weatherwax 2010-02-25 // // email: wax@alum.mit.edu // // Please send comments and especially bug reports to the // above email address. // //----- using namespace boost::numeric::ublas; using namespace boost::math; void ht_regularization( matrix & M, double gamma, size_t num_of_measurements ){ // H(ypothesis) T(esting) regularization // // Input: // M : A covariance matrix // gamma : The amount of regularization. // The input gamma in this case is 1-alpha, where alpha is the probability of a // Type I error, or the probability of rejecting H_0 (the hypothesis that // \rho_{ij} = 0 or that the population correlation is zero) when H_0 is true thus: // gamma ~ 0.0 => alpha = 1.0 => less (no) regularization // gamma ~ 1.0 => alpha = 0.0 => maxumum regularization // num_of_measurements : The number of measurements that went into computing this covariance element // Output: // M : A regularized covariance matrix // bool verbose = false; double alpha = 1.0 - gamma; size_t Sn = num_of_measurements; size_t N = M.size1(); students_t dist(Sn - 2); double t = quantile(complement(dist, alpha/2)); for( size_t ii=0; ii