go: remove prints

This commit is contained in:
NunoSempere 2024-02-16 14:17:28 +01:00
parent 5029f67429
commit 14e298c3c9

View File

@ -51,7 +51,7 @@ type func64 func() float64
func sample_mixture(fs []func64, weights []float64) float64 {
fmt.Println("weights initially: ", weights)
// fmt.Println("weights initially: ", weights)
var sum_weights float64 = 0
for _, weight := range weights {
sum_weights += weight
@ -75,17 +75,20 @@ func sample_mixture(fs []func64, weights []float64) float64 {
break
}
}
fmt.Println(cumsummed_normalized_weights)
// fmt.Println(cumsummed_normalized_weights)
if flag == 0 {
result = fs[len(fs)-1]()
}
return result
// return weights[0]
}
func main() {
var p_a float64 = 0.8
var p_b float64 = 0.5
var p_c float64 = p_a * p_b
ws := [4](float64){1 - p_c, p_c / 2, p_c / 4, p_c / 4}
sample_0 := func() float64 { return 0 }
sample_1 := func() float64 { return 1 }
@ -93,18 +96,10 @@ func main() {
sample_many := func() float64 { return sample_to(2, 10) }
fs := [4](func64){sample_0, sample_1, sample_few, sample_many}
var p_a float64 = 0.8
var p_b float64 = 0.5
var p_c float64 = p_a * p_b
ws := [4](float64){1 - p_c, p_c / 2, p_c / 4, p_c / 4}
fmt.Println("weights #1", ws)
var n_samples int = 1_000_000
var avg float64 = 0
for i := 0; i < n_samples; i++ {
x := sample_mixture(fs[0:], ws[0:])
fmt.Printf("%v\n", x)
avg += x
avg += sample_mixture(fs[0:], ws[0:])
}
avg = avg / float64(n_samples)
fmt.Printf("Average: %v\n", avg)