Statistical functions written in Scala