gonum.org/v1/gonum@v0.14.0/mathext/mvgamma_test.go (about)

     1  // Copyright ©2016 The Gonum Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package mathext
     6  
     7  import (
     8  	"math"
     9  	"testing"
    10  )
    11  
    12  func TestMvLgamma(t *testing.T) {
    13  	t.Parallel()
    14  	// Values compared with scipy
    15  	for i, test := range []struct {
    16  		v   float64
    17  		dim int
    18  		ans float64
    19  	}{
    20  		{10, 5, 58.893841851237397},
    21  		{3, 1, 0.69314718055994529},
    22  	} {
    23  		ans := MvLgamma(test.v, test.dim)
    24  		if math.Abs(test.ans-ans) > 1e-13 {
    25  			t.Errorf("Case %v. got=%v want=%v.", i, ans, test.ans)
    26  		}
    27  	}
    28  }