github.com/lingyao2333/mo-zero@v1.4.1/core/mathx/entropy_test.go (about)

     1  package mathx
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func TestCalcEntropy(t *testing.T) {
    10  	const total = 1000
    11  	const count = 100
    12  	m := make(map[interface{}]int, total)
    13  	for i := 0; i < total; i++ {
    14  		m[i] = count
    15  	}
    16  	assert.True(t, CalcEntropy(m) > .99)
    17  }