stat/combin: test Binomial for "large" n
package combin
import (
+ "math/big"
"testing"
"github.com/gonum/floats"
@@ -77,6 +78,18 @@ func TestBinomial(t *testing.T) {
t.Errorf("Case %v: Binomial mismatch. Got %v, want %v.", cas, ans, test.ans)
}
}
+ var (
+ n = 61
+ want big.Int
+ got big.Int
+ )
+ for k := 0; k <= n; k++ {
+ want.Binomial(int64(n), int64(k))
+ got.SetInt64(int64(Binomial(n, k)))
+ if want.Cmp(&got) != 0 {
+ t.Errorf("Case n=%v,k=%v: Binomial mismatch for large n. Got %v, want %v.", n, k, got, want)
+ }
+ }
}
func TestGeneralizedBinomial(t *testing.T) {
