From 3924027c311d166f7e6cbfa8b8c9fa61b79e3cf7 Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Tue, 1 Oct 2024 09:44:45 +0200 Subject: [PATCH] add summary stats command --- fermi.go | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/fermi.go b/fermi.go index aff812e..2e4757b 100644 --- a/fermi.go +++ b/fermi.go @@ -130,7 +130,7 @@ func prettyPrintDist(dist Dist) { }) 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("=> ") pretty.PrettyPrint2Floats(low, high) @@ -173,24 +173,19 @@ func prettyPrintStats(dist Dist) { sort.Slice(sorted_xs, func(i, j int) bool { return sorted_xs[i] < sorted_xs[j] }) - ci_01 := sorted_xs[int(math.Round(float64(n)*0.01))] - ci_05 := sorted_xs[int(math.Round(float64(n)*0.05))] - ci_10 := sorted_xs[int(math.Round(float64(n)*0.10))] - ci_25 := sorted_xs[int(math.Round(float64(n)*0.25))] - ci_50 := sorted_xs[int(math.Round(float64(n)*0.50))] - ci_75 := sorted_xs[int(math.Round(float64(n)*0.75))] - ci_90 := sorted_xs[int(math.Round(float64(n)*0.90))] - ci_95 := sorted_xs[int(math.Round(float64(n)*0.95))] - ci_99 := sorted_xs[int(math.Round(float64(n)*0.99))] - fmt.Printf("ci 1%%: %f\n", ci_01) - fmt.Printf("ci 5%%: %f\n", ci_05) - fmt.Printf("ci 10%%: %f\n", ci_10) - fmt.Printf("ci 25%%: %f\n", ci_25) - 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) + print_ci := func(ci float64, prefix string) { + x := sorted_xs[int(math.Round(float64(n)*ci))] + fmt.Printf("%s%f\n", prefix, x) + } + print_ci(0.01, "ci 1%: ") + print_ci(0.05, "ci 5%: ") + print_ci(0.10, "ci 10%: ") + print_ci(0.25, "ci 25%: ") + print_ci(0.50, "ci 50%: ") + print_ci(0.75, "ci 75%: ") + print_ci(0.90, "ci 90%: ") + print_ci(0.95, "ci 95%: ") + print_ci(0.99, "ci 99%: ") }