Skip to content

Instantly share code, notes, and snippets.

View darkfrog26's full-sized avatar
🦊
Crazy like a fox

Matt Hicks darkfrog26

🦊
Crazy like a fox
View GitHub Profile
@darkfrog26
darkfrog26 / RegressionApp.scala
Last active September 11, 2018 17:18 — forked from otobrglez/RegressionApp.scala
Linear regression with pure Scala
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))