aboutsummaryrefslogtreecommitdiff
path: root/cli/cli_test.go
blob: 8290bce3e0d65b8ff486bab0e7a0bcf364a3e693 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

package cli

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestBacktestStatsUseUnroundedSamples(t *testing.T) {
	absErrors := []float64{0, 0.1, 0.1}

	assert.InDelta(t, 1.0/15, meanAbsErr(absErrors), 1e-12)
	assert.InDelta(t, 1.0/30, stdErrAbsErr(absErrors), 1e-12)
}

func TestErrorDistributionUsesNearestRank(t *testing.T) {
	distribution := errorDistribution([]float64{1, 2, 3, 4}, []float64{50, 75, 99})

	assert.Equal(t, 2.0, distribution[50])
	assert.Equal(t, 3.0, distribution[75])
	assert.Equal(t, 4.0, distribution[99])
}