Near-Optimality of Contrastive Divergence Algorithms