probabilistic algorithms in scala