mirror of
https://github.com/gonum/gonum.git
synced 2025-10-29 17:51:54 +08:00
Documentation fixes to recent sample commit
This commit is contained in:
@@ -26,7 +26,7 @@ func ExampleMetropolisHastings_samplingRate() {
|
||||
|
||||
tmp := make([]float64, max(rate, burnin))
|
||||
|
||||
// First deal with burnin
|
||||
// First deal with burnin.
|
||||
tmp = tmp[:burnin]
|
||||
MetropolisHastings(tmp, initial, target, proposal, nil)
|
||||
// The final sample in tmp in the final point in the chain.
|
||||
|
||||
@@ -101,7 +101,7 @@ func Rejection(samples []float64, target dist.LogProber, proposal dist.RandLogPr
|
||||
px := target.LogProb(v)
|
||||
accept := math.Exp(px-qx) / c
|
||||
if accept > 1 {
|
||||
// Invalidate the whole result and return a failure
|
||||
// Invalidate the whole result and return a failure.
|
||||
for i := range samples {
|
||||
samples[i] = math.NaN()
|
||||
}
|
||||
@@ -118,6 +118,7 @@ func Rejection(samples []float64, target dist.LogProber, proposal dist.RandLogPr
|
||||
return nProposed, true
|
||||
}
|
||||
|
||||
// MHProposal defines a proposal distribution for Metropolis Hastings.
|
||||
type MHProposal interface {
|
||||
// ConditionalDist returns the probability of the first argument conditioned on
|
||||
// being at the second argument
|
||||
@@ -125,7 +126,7 @@ type MHProposal interface {
|
||||
ConditionalLogProb(x, y float64) (prob float64)
|
||||
|
||||
// ConditionalRand generates a new random location conditioned being at the
|
||||
// location y
|
||||
// location y.
|
||||
ConditionalRand(y float64) (x float64)
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ func TestLatinHypercube(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImportance(t *testing.T) {
|
||||
// Test by finding the expected value of a Normal
|
||||
// Test by finding the expected value of a Normal.
|
||||
trueMean := 3.0
|
||||
target := dist.Normal{Mu: trueMean, Sigma: 2}
|
||||
proposal := dist.Normal{Mu: 0, Sigma: 5}
|
||||
@@ -53,7 +53,7 @@ func TestImportance(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRejection(t *testing.T) {
|
||||
// Test by finding the expected value of a Normal
|
||||
// Test by finding the expected value of a Normal.
|
||||
trueMean := 3.0
|
||||
target := dist.Normal{Mu: trueMean, Sigma: 2}
|
||||
proposal := dist.Normal{Mu: 0, Sigma: 5}
|
||||
@@ -80,7 +80,7 @@ func (c condNorm) ConditionalLogProb(x, y float64) float64 {
|
||||
}
|
||||
|
||||
func TestMetropolisHastings(t *testing.T) {
|
||||
// Test by finding the expected value of a Normal
|
||||
// Test by finding the expected value of a Normal.
|
||||
trueMean := 3.0
|
||||
target := dist.Normal{Mu: trueMean, Sigma: 2}
|
||||
proposal := condNorm{Sigma: 5}
|
||||
|
||||
Reference in New Issue
Block a user