github.com/jgbaldwinbrown/perf@v0.1.1/benchmath/mktables.go (about)

     1  // Copyright 2022 The Go 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  //go:build ignore
     6  // +build ignore
     7  
     8  // Mktables pre-computes statistical tables.
     9  package main
    10  
    11  import (
    12  	"fmt"
    13  
    14  	"github.com/aclements/go-moremath/stats"
    15  )
    16  
    17  func main() {
    18  	var s1, s2 []float64
    19  
    20  	// Compute minimal P-value for the U-test given different
    21  	// sample sizes.
    22  	fmt.Printf("var uTestMinP = []float64{\n")
    23  	for n := 1; n < 10; n++ {
    24  		// The P-value is minimized when the order statistic
    25  		// is maximally separated.
    26  		s1 = append(s1, -1)
    27  		s2 = append(s2, 1)
    28  		res, err := stats.MannWhitneyUTest(s1, s2, stats.LocationDiffers)
    29  		if err != nil {
    30  			panic(err)
    31  		}
    32  		fmt.Printf("\t%d: %v,\n", n, res.P)
    33  	}
    34  	fmt.Printf("}\n")
    35  }