Last active
October 24, 2016 19:56
-
-
Save soaxelbrooke/b475efd7b72fd36da17eb83cd582957d to your computer and use it in GitHub Desktop.
Fitting beta distributions in Scala π
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.sys.process._ | |
object BetaDistributionFit { | |
val distName: String = "beta" | |
def fitCommand(samples: Seq[Double]): Seq[String] = | |
Seq("python", "-c", | |
s""" | |
|from scipy import stats | |
|samples = [${samples.mkString(",")}] | |
|print(','.join(map(str, stats.$distName.fit(samples)))) | |
""".stripMargin) | |
def fit(samples: Seq[Double]): Seq[Double] = | |
fitCommand(samples).!!.split(",").map(_.toDouble) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More monads, please.