Permalink
Browse files

implement poisson distribution

  • Loading branch information...
1 parent fc764b1 commit 7b8dab4020abd75a7fbbc58812520059a6a4d300 @hiratara committed Apr 4, 2012
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/main/scala/hiratara/Statistics.scala
@@ -137,4 +137,10 @@ object Statistics {
def distribution(x: Int) = combi(n, x).toDouble * pow(p, x) * pow(1 - p, n - x)
distribution _
}
+
+ def poissonDistribution(m: Double): (Int) => Double = {
+ import scala.math.pow
+ def distribution(x: Int) = pow(m, x).toDouble / pow(2.71828, m).toDouble / factor(x).toDouble
+ distribution _
+ }
}

0 comments on commit 7b8dab4

Please sign in to comment.