Statistical Analysis of Coevolution in Protein Structure and in Ecology