an algorithm of deviance