Skip to content

Instantly share code, notes, and snippets.

@mepcotterell
Created October 9, 2012 18:56
Show Gist options
  • Save mepcotterell/3860709 to your computer and use it in GitHub Desktop.
Save mepcotterell/3860709 to your computer and use it in GitHub Desktop.
Bayes
import scalation.linalgebra.VectorD
import scalation.random.Normal
object NaiveBayes extends App {
val miles = VectorD(1300, 900, 2000, 1450, 2190, 1600, 300, 3100, 1521, 1786)
val mean = milel.sum / miles.dim.toDouble
val variance = ((miles - mean) ~^ 2).sum / (miles.dim.toDouble - 1)
def PrMiles (x: Double) = Normal(mean, variance).pf(x)
} // NaiveBayes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment