func exactFor(AA, Aa, aa int64) (p float64) {
	A := AA*2 + Aa
	a := aa*2 + Aa
	N := AA + Aa + aa

	// big.Int where needed:
	nAa := big.NewInt(Aa)

	// Generate intermediates
	var denom, nexp big.Int

	// Numerator
	nexp.Exp(big.NewInt(2), nAa, nil)
	nexp.Mul(&nexp, memoizedFactorial.(func(int64, int64) *big.Int)(1, A))
	nexp.Mul(&nexp, memoizedFactorial.(func(int64, int64) *big.Int)(1, a))

	// Denominator
	denom.Add(&denom, memoizedFactorial.(func(int64, int64) *big.Int)(N+1, 2*N))
	denom.Mul(&denom, memoizedFactorial.(func(int64, int64) *big.Int)(1, AA))
	denom.Mul(&denom, memoizedFactorial.(func(int64, int64) *big.Int)(1, Aa))
	denom.Mul(&denom, memoizedFactorial.(func(int64, int64) *big.Int)(1, aa))

	// Results
	var ratNum, ratDenom big.Rat
	ratNum.SetInt(&nexp)
	ratDenom.SetInt(&denom)
	final, _ := new(big.Rat).Quo(&ratNum, &ratDenom).Float64()

	return final
}
// exactFor yields the probability of observing exactly Aa heterozygotes in a
// sample of AA+Aa+aa individuals with Aa+2*aa minor alleles.
exactFor yields the probability of observing exactly Aa heterozygotes in a
sample of AA+Aa+aa individuals with Aa+2*aa minor alleles.
// exactFor yields the probability of observing exactly Aa heterozygotes in a // sample of AA + Aa + aa individuals with Aa + 2 * aa minor alleles .
func exactFor(AA, Aa, aa int64) (p float64) {
	A := AA*2 + Aa
	a := aa*2 + Aa
	N := AA + Aa + aa
	nAa := big.NewInt(Aa)
	var denom, nexp big.Int
	nexp.Exp(big.NewInt(2), nAa, nil)
	nexp.Mul(&nexp, memoizedFactorial.(func(int64, int64) *big.Int)(1, A))
	nexp.Mul(&nexp, memoizedFactorial.(func(int64, int64) *big.Int)(1, a))
	denom.Add(&denom, memoizedFactorial.(func(int64, int64) *big.Int)(N+1, 2*N))
	denom.Mul(&denom, memoizedFactorial.(func(int64, int64) *big.Int)(1, AA))
	denom.Mul(&denom, memoizedFactorial.(func(int64, int64) *big.Int)(1, Aa))
	denom.Mul(&denom, memoizedFactorial.(func(int64, int64) *big.Int)(1, aa))
	var ratNum, ratDenom big.Rat
	ratNum.SetInt(&nexp)
	ratDenom.SetInt(&denom)
	final, _ := new(big.Rat).Quo(&ratNum, &ratDenom).Float64()
	return final
}
func exactFor ( AA , Aa , aa int64 ) ( p float64 ) { A := AA * 2 + Aa a := aa * 2 + Aa N := AA + Aa + aa nAa := big . NewInt ( Aa ) var denom , nexp big . Int nexp . Exp ( big . NewInt ( 2 ) , nAa , nil ) nexp . Mul ( & nexp , memoizedFactorial . ( func ( int64 , int64 ) * big . Int ) ( 1 , A ) ) nexp . Mul ( & nexp , memoizedFactorial . ( func ( int64 , int64 ) * big . Int ) ( 1 , a ) ) denom . Add ( & denom , memoizedFactorial . ( func ( int64 , int64 ) * big . Int ) ( N + 1 , 2 * N ) ) denom . Mul ( & denom , memoizedFactorial . ( func ( int64 , int64 ) * big . Int ) ( 1 , AA ) ) denom . Mul ( & denom , memoizedFactorial . ( func ( int64 , int64 ) * big . Int ) ( 1 , Aa ) ) denom . Mul ( & denom , memoizedFactorial . ( func ( int64 , int64 ) * big . Int ) ( 1 , aa ) ) var ratNum , ratDenom big . Rat ratNum . SetInt ( & nexp ) ratDenom . SetInt ( & denom ) final , _ := new ( big . Rat ) . Quo ( & ratNum , & ratDenom ) . Float64 ( ) return final }
exactFor yields the probability of observing exactly Aa heterozygotes in a
sample of AA+Aa+aa individuals with Aa+2*aa minor alleles.
exactFor yields the probability of observing exactly Aa heterozygotes in a sample of AA + Aa + aa individuals with Aa + 2 * aa minor alleles .
// big.Int where needed: // Generate intermediates // Numerator // Denominator // Results