a wald hypothesis testing algorithm