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))]
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%: ")
}