示例#1
0
func BinomBetaPriCrI(α, β, alpha float64, n, k int64) (float64, float64) {
	/*
		k			observed successes
		n			total number of observations
		α			beta prior a
		β			beta prior b
		alpha			posterior probability that the true proportion lies outside the credible interval
	*/

	var low, upp float64
	low = s.BetaInv_CDF_For(alpha/2.0, α+float64(k), β+float64(n-k))
	upp = s.BetaInv_CDF_For(1.0-alpha/2.0, α+float64(k), β+float64(n-k))
	return low, upp
}
示例#2
0
// Quantile, Jeffrey's prior
func BinomJeffPriQtl(k, n int64, p float64) float64 {
	var α, β float64
	α = 0.5
	β = 0.5
	if k > n {
		panic(fmt.Sprintf("The number of observed successes (k) must be <= number of trials (n)"))
	}
	return s.BetaInv_CDF_For(α+float64(k), β+float64(n-k), p)
}
示例#3
0
// Quantile, Beta prior
func BinomBetaPriQtl(k, n int64, α, β, p 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 greater than zero"))
	}
	return s.BetaInv_CDF_For(α+float64(k), β+float64(n-k), p)
}
示例#4
0
// Quantile, Flat prior
func BinomFlatPriQtl(k, n int64, p float64) float64 {
	var α, β float64
	if k > n {
		panic(fmt.Sprintf("The number of observed successes (k) must be <= number of trials (n)"))
	}

	α = float64(k + 1)
	β = float64(n - k + 1)

	if α <= 0 || β <= 0 {
		panic(fmt.Sprintf("The parameters of the prior must be greater than zero"))
	}
	return s.BetaInv_CDF_For(α, β, p)
}