Exemplo n.º 1
0
// BinomPiPDFFPri returns posterior PDF of the Binomial proportion, Flat prior.
func BinomPiPDFFPri(k, n int64) func(x float64) float64 {
	if k > n {
		panic(fmt.Sprintf("The number of observed successes (k) must be <= number of trials (n)"))
	}
	α := 1.0
	β := 1.0
	return dst.BetaPDF(α+float64(k), β+float64(n-k))
}
Exemplo n.º 2
0
// BinomPiPDFBPri returns posterior PDF of the Binomial proportion, general Beta prior.
func BinomPiPDFBPri(k, n int64, α, β float64) func(x float64) float64 {
	if k > n {
		panic(fmt.Sprintf("The number of observed successes (k) must be <= number of trials (n)"))
	}
	if α < 0 || β < 0 {
		panic(fmt.Sprintf("The parameters of the prior must be non-negative"))
	}
	return dst.BetaPDF(α+float64(k), β+float64(n-k))
}
Exemplo n.º 3
0
// BinomPiPDFHPri returns posterior PDF of the Binomial proportion, Haldane prior.
// see Aitkin 2010: 143 for cautions
func BinomPiPDFHPri(k, n int64) func(x float64) float64 {
	var α, β float64
	α = 0.0
	β = 0.0
	if k > n {
		panic(fmt.Sprintf("The number of observed successes (k) must be <= number of trials (n)"))
	}
	return dst.BetaPDF(α+float64(k), β+float64(n-k))
}