Example #1
0
func jointAxis(kdes map[gcstats.PhaseKind]*stats.KDE, maxPause float64) []float64 {
	var lo, hi float64
	for i, kde := range kdes {
		if i == 0 {
			lo, hi = kde.Bounds()
		} else {
			lo1, hi1 := kde.Bounds()
			lo, hi = math.Min(lo, lo1), math.Max(hi, hi1)
		}
	}
	hi = math.Max(hi, maxPause)
	return vec.Linspace(lo, hi, samples)
}
Example #2
0
func testInvCDF(t *testing.T, dist Dist, bounded bool) {
	inv := InvCDF(dist)
	name := fmt.Sprintf("InvCDF(%+v)", dist)
	cdfName := fmt.Sprintf("CDF(%+v)", dist)

	// Test bounds.
	vals := map[float64]float64{-0.01: nan, 1.01: nan}
	if !bounded {
		vals[0] = -inf
		vals[1] = inf
	}
	testFunc(t, name, inv, vals)

	if bounded {
		lo, hi := inv(0), inv(1)
		vals := map[float64]float64{
			lo - 0.01: 0, lo: 0,
			hi: 1, hi + 0.01: 1,
		}
		testFunc(t, cdfName, dist.CDF, vals)
		if got := dist.CDF(lo + 0.01); !(got > 0) {
			t.Errorf("%s(0)=%v, but %s(%v)=0", name, lo, cdfName, lo+0.01)
		}
		if got := dist.CDF(hi - 0.01); !(got < 1) {
			t.Errorf("%s(1)=%v, but %s(%v)=1", name, hi, cdfName, hi-0.01)
		}
	}

	// Test points between.
	vals = map[float64]float64{}
	for _, p := range vec.Linspace(0, 1, 11) {
		if p == 0 || p == 1 {
			continue
		}
		x := inv(p)
		vals[x] = x
	}
	testFunc(t, fmt.Sprintf("InvCDF(CDF(%+v))", dist),
		func(x float64) float64 {
			return inv(dist.CDF(x))
		},
		vals)
}
Example #3
0
func doMUDMap(s *gcstats.GcStats) {
	windows := ints(vec.Logspace(6, 9, 100, 10))
	muds := make([]*gcstats.MUD, len(windows))
	for i, windowNS := range windows {
		muds[i] = s.MutatorUtilizationDistribution(windowNS)
	}
	// gnuplot "nonuniform matrix" format
	fmt.Printf("%d ", len(windows)+1)
	for _, windowNS := range windows {
		fmt.Printf("%d ", windowNS)
	}
	fmt.Print("\n")
	utils := vec.Linspace(0, 1, 100)
	for _, util := range utils {
		fmt.Printf("%g ", util)
		for _, mud := range muds {
			fmt.Printf("%g ", mud.CDF(util))
		}
		fmt.Print("\n")
	}
}