Skip to content

Instantly share code, notes, and snippets.

@antonycourtney
Created March 23, 2015 23:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antonycourtney/023f5062ef46b36e5b31 to your computer and use it in GitHub Desktop.
Save antonycourtney/023f5062ef46b36e5b31 to your computer and use it in GitHub Desktop.
Breeze MultivariateGaussian Timing Test
import breeze.linalg._
import breeze.math._
import breeze.stats.distributions._
object TimingTest {
def timeIt[R](block: => R): R = {
val t0 = System.nanoTime()
val result = block // call-by-name
val t1 = System.nanoTime()
val elapsed = t1 - t0
println("Elapsed time: " + elapsed + "ns (" + elapsed / 1e9 + " sec)")
result
}
def testMVGaussian(): Double = {
val dm = DenseMatrix((1.0,-0.9),(-0.9,1.0))
val mvd = MultivariateGaussian(DenseVector(0.0,0.0),dm)
val n = 10000
var zs : IndexedSeq[DenseVector[Double]] = null
for (i <- 1 to 100) {
zs = mvd.sample(n)
}
zs(n-1)(1)
}
def main(args: Array[String]) = {
val v = timeIt { testMVGaussian }
println("v: " + v)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment