This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.concurrent._ | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent.duration._ | |
// based on the original work: https://gist.github.com/otobrglez/08e9064209c9fc777ea5/d8000c300d2fd72db5a3445b8a93612680acaabb | |
// For kicks, I cleaned this up | |
object Regression { | |
def linear(pairs: Seq[Data]): Future[Regression] = for { | |
x1 <- Future(pairs.foldLeft(0.0)((sum, d) => sum + d.x)) | |
y1 <- Future(pairs.foldLeft(0.0)((sum, d) => sum + d.y)) |