Skip to content

Instantly share code, notes, and snippets.

@jonnylaw
Last active July 18, 2016 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonnylaw/5dbc77be9f92e9f93a16d0718c375d33 to your computer and use it in GitHub Desktop.
Save jonnylaw/5dbc77be9f92e9f93a16d0718c375d33 to your computer and use it in GitHub Desktop.
type Likelihood = Double
case class Observation(y: Int, x: DenseVector[Double])
def likelihood(data: Vector[Observation]): Parameters => Likelihood = p => {
val ll = data.
map{ y => Poisson(exp(p.dot(y.x))).logProbabilityOf(y.y) }.
sum
exp(ll)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment