diff options
Diffstat (limited to 'cli')
| -rw-r--r-- | cli/cli.go | 10 |
1 files changed, 2 insertions, 8 deletions
@@ -106,10 +106,7 @@ func runBacktest(db *sql.DB) error { }) w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) fmt.Fprintln(w, "computed\treference\terr %\tride") - limit := 10 - if len(samples) < limit { - limit = len(samples) - } + limit := min(len(samples), 10) for _, s := range samples[:limit] { fmt.Fprintf(w, "%s\t%s\t%+.1f\t%s (%s)\n", s.computed.Round(time.Second), s.reference.Round(time.Second), s.relErrorPct, s.name, s.externalID) } @@ -162,10 +159,7 @@ func errorDistribution(absErrors []float64, percentiles []float64) map[float64]f sort.Float64s(sorted) distribution := map[float64]float64{} for _, p := range percentiles { - index := int(math.Ceil(p/100*float64(len(sorted))) - 1) - if index < 0 { - index = 0 - } + index := max(int(math.Ceil(p/100*float64(len(sorted)))-1), 0) if index >= len(sorted) { index = len(sorted) - 1 } |
