func ComputeProbability()

in pkg/trimaran/lowriskovercommitment/beta.go [173:191]


func ComputeProbability(mu, sigma, threshold float64) (float64, *BetaDistribution) {
	if mu == 0 || (sigma == 0 && mu <= threshold) {
		return 1, nil
	}
	if sigma == 0 && mu > threshold {
		return 0, nil
	}
	m1 := mu
	m2 := (sigma * sigma) + (mu * mu)
	betaDist := NewBetaDistribution(1, 1)
	if !betaDist.MatchMoments(m1, m2) {
		return 0, nil
	}
	belowLimit := betaDist.DistributionFunction(threshold)
	if math.IsNaN(belowLimit) {
		return 1, betaDist
	}
	return belowLimit, betaDist
}