示例#1
0
// BinomPiCDFFPri returns posterior CDF of the Binomial proportion, Flat prior.
func BinomPiCDFFPri(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.BetaCDF(α+float64(k), β+float64(n-k))
}
示例#2
0
// BinomPiCDFBPri returns posterior CDF of the Binomial proportion, general Beta prior.
func BinomPiCDFBPri(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.BetaCDF(α+float64(k), β+float64(n-k))
}
示例#3
0
// BinomPiCDFHPri returns posterior CDF of the Binomial proportion, Haldane prior.
// see Aitkin 2010: 143 for cautions
func BinomPiCDFHPri(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.BetaCDF(α+float64(k), β+float64(n-k))
}