In this paper, we studied the security of anonymous communications in mobile ad hoc networks. We first proposed a statistical model for anonymous communications. By employing the principle of Bayesian inference, we were able to transform a traffic analysis problem into a sampling problem. Metropolis-Hastings algorithm was implemented to analyze the sampling problem. Experiments were conducted on Threshold Mix to evaluate the correctness and efficiency of this method. Compared with traditional traffic analysis methods, our method provides more legitimate probability results and has the potential to be used widely.