argiopetech / base

Bayesian Analysis for Stellar Evolution
http://webfac.db.erau.edu/~vonhippt/base9/
11 stars 4 forks source link

SampleMass Metropolis-Hastings sampler #55

Closed argiopetech closed 10 years ago

argiopetech commented 10 years ago

The current brute force numerical integration method used by sampleMass is sufficiently computationally complex that it is not useful in the general case. The following Metropolis Hastings sampler pseudocode should be more effective:

set burnin = 50 (say)
foreach sampledParameter
  foreach star
     for (iter = 0; iter < burnin; iter++)
      proposedMass = currentMass + randomStep1
      proposedMassRatio = currentMassRatio + randomStep2
      MHratio = logpost(proposedMass, proposedMassRatio, sampledParameter) - 
                     logpost(currentMass, currentMassRatio, sampledParameter)
      if (log(randomUniform) < MHratio)
        currentMass = proposedMass
        currentMassRatio = proposedMassRatio
      endif
    endfor
  endforeach
endforeach
argiopetech commented 10 years ago

Implemented in 821c30e554582997e1beb5ec045ad7dce77e2851.