stat/distuv: fix StudentsT.Variance domain bound and provide full test coverage
MODIFY
stat/distuv/studentst_test.go
stat/distuv/studentst_test.go
@@ -67,6 +67,9 @@ func testStudentsT(t *testing.T, c StudentsT, i int) {
if c.Mu != c.Mode() {
t.Errorf("Mismatch in mode value: got %v, want %g", c.Mode(), c.Mu)
}
+ if c.NumParameters() != 3 {
+ t.Errorf("Mismatch in NumParameters: got %v, want 3", c.NumParameters())
+ }
}
func TestStudentsTQuantile(t *testing.T) {
@@ -90,3 +93,17 @@ func TestStudentsTQuantile(t *testing.T) {
}
}
}
+
+func TestStudentsVarianceSpecial(t *testing.T) {
+ t.Parallel()
+ dist := StudentsT{0, 1, 1, nil}
+ variance := dist.Variance()
+ if !math.IsNaN(variance) {
+ t.Errorf("Expected NaN variance for Nu <= 1, got %v", variance)
+ }
+ dist = StudentsT{0, 1, 2, nil}
+ variance = dist.Variance()
+ if !math.IsInf(variance, 1) {
+ t.Errorf("Expected +Inf variance for 1 < Nu <= 2, got %v", variance)
+ }
+}

stat/distuv: fix StudentsT.Variance domain bound and provide full test coverage