add summary stats command

This commit is contained in:
NunoSempere 2024-10-01 09:44:45 +02:00
parent 4573faee10
commit 3924027c31

View File

@ -130,7 +130,7 @@ func prettyPrintDist(dist Dist) {
}) })
low := sorted_xs[int(math.Round(float64(n)*0.05))] low := sorted_xs[int(math.Round(float64(n)*0.05))]
high := sorted_xs[int(math.Round(float64(n)*0.05))] high := sorted_xs[int(math.Round(float64(n)*0.95))]
fmt.Printf("=> ") fmt.Printf("=> ")
pretty.PrettyPrint2Floats(low, high) pretty.PrettyPrint2Floats(low, high)
@ -173,24 +173,19 @@ func prettyPrintStats(dist Dist) {
sort.Slice(sorted_xs, func(i, j int) bool { sort.Slice(sorted_xs, func(i, j int) bool {
return sorted_xs[i] < sorted_xs[j] return sorted_xs[i] < sorted_xs[j]
}) })
ci_01 := sorted_xs[int(math.Round(float64(n)*0.01))] print_ci := func(ci float64, prefix string) {
ci_05 := sorted_xs[int(math.Round(float64(n)*0.05))] x := sorted_xs[int(math.Round(float64(n)*ci))]
ci_10 := sorted_xs[int(math.Round(float64(n)*0.10))] fmt.Printf("%s%f\n", prefix, x)
ci_25 := sorted_xs[int(math.Round(float64(n)*0.25))] }
ci_50 := sorted_xs[int(math.Round(float64(n)*0.50))] print_ci(0.01, "ci 1%: ")
ci_75 := sorted_xs[int(math.Round(float64(n)*0.75))] print_ci(0.05, "ci 5%: ")
ci_90 := sorted_xs[int(math.Round(float64(n)*0.90))] print_ci(0.10, "ci 10%: ")
ci_95 := sorted_xs[int(math.Round(float64(n)*0.95))] print_ci(0.25, "ci 25%: ")
ci_99 := sorted_xs[int(math.Round(float64(n)*0.99))] print_ci(0.50, "ci 50%: ")
fmt.Printf("ci 1%%: %f\n", ci_01) print_ci(0.75, "ci 75%: ")
fmt.Printf("ci 5%%: %f\n", ci_05) print_ci(0.90, "ci 90%: ")
fmt.Printf("ci 10%%: %f\n", ci_10) print_ci(0.95, "ci 95%: ")
fmt.Printf("ci 25%%: %f\n", ci_25) print_ci(0.99, "ci 99%: ")
fmt.Printf("ci 50%%: %f\n", ci_50)
fmt.Printf("ci 75%%: %f\n", ci_75)
fmt.Printf("ci 90%%: %f\n", ci_90)
fmt.Printf("ci 95%%: %f\n", ci_95)
fmt.Printf("ci 99%%: %f\n", ci_99)
} }