Skip to content

Commit

Permalink
Cleaning up code in MH-MCMC
Browse files Browse the repository at this point in the history
  • Loading branch information
mandar2812 committed Jan 6, 2017
1 parent 91fd052 commit 5686482
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,11 @@ case class AbstractMetropolisHastings[T, Dist <: Density[T] with Rand[T]](
implicit rand:RandBasis=Rand, f: Field[T]) extends
BaseMetropolisHastings[T](logLikelihoodF, init, burnIn, dropCount)(rand) { self =>

def proposalDraw(x: T): T = f.plus(proposalStep.draw(),x)

//val likelihood = logLikelihood
override def proposalDraw(x: T): T = f.plus(proposalStep.draw(),x)

val proposal = proposalStep


def observe(x: T) = this.copy(logLikelihoodF, proposal, burnIn = 0L, init = x)

//override def likelihoodRatio(start: T, end: T): Double = math.exp(logLikelihoodFunc(end) - logLikelihoodFunc(start))

override def logTransitionProbability(start: T, end: T) = 0.0
}
4 changes: 2 additions & 2 deletions scripts/probModels.sc
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ val gModel = new ContinuousMCMCModel(prior, likelihood, prop, 10000L)

val posterior = gModel.posterior(data)

val samples = (1 to 1000).map(_ => {posterior.sample()})
val samples = (1 to 3000).map(_ => {posterior.sample()})

histogram(data)
title("Histogram of data")


scatter(iidPrior(1000).sample())
scatter(iidPrior(3000).sample())
hold()
scatter(samples)
legend(List("Prior", "Posterior"))
Expand Down

0 comments on commit 5686482

Please sign in to comment.