Computing statistics using squared probabilities