title: summary statistics in scala
body: <p>How can I elegantly calculate summary statistics (e.g. mean variance) elegantly in scala per group here in this example per each different metric(name)?</p>
  
  <pre><code>case class MeasureUnit(name: String, value: Double)
  
  Seq(MeasureUnit("metric1", 0.04), MeasureUnit("metric1", 0.09),
    MeasureUnit("metric2", 0.64), MeasureUnit("metric2", 0.34), MeasureUnit("metric2", 0.84))
  </code></pre>
  
  <p>An excellent example how to calculate mean /variance per property is <a href="https://chrisbissell.wordpress.com/2011/05/23/a-simple-but-very-flexible-statistics-library-in-scala/" rel="nofollow noreferrer">https://chrisbissell.wordpress.com/2011/05/23/a-simple-but-very-flexible-statistics-library-in-scala/</a>
  but that does not cover the grouping.</p>