Code for implementing the cobs covariance algorithm