time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

commit 4544adb3d0ae0257cb9b728b4e6eca6dd2d0b79e
parent 651ade8b4798fb9b3f3c87c3631663ea2d1d827d
Author: NunoSempere <nuno.sempere@protonmail.com>
Date:   Fri, 16 Feb 2024 10:10:16 +0100

wrangle mixture syntax

Diffstat:
Mgo/notes.md | 4+++-
Mgo/squiggle.go | 12++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/go/notes.md b/go/notes.md @@ -1,5 +1,7 @@ - [x] Hello world program - [x] Look into randomness sources in go - rand/v2 api: <https://pkg.go.dev/math/rand/v2> -- [ ] Test with a million samples of a simple lognormal, just to get a sense of speed +- [x] Test with a million samples of a simple lognormal, just to get a sense of speed - [ ] Add mixture distribution +- [ ] Look into go routines for filling up an array. +- [ ] Anonymous functions for nested: https://stackoverflow.com/questions/74523441/nested-functions-in-go diff --git a/go/squiggle.go b/go/squiggle.go @@ -47,6 +47,12 @@ func sample_to(low float64, high float64) float64 { return math.Exp(sample_normal_from_90_ci(loglow, loghigh)) } +type func64 func() float64 + +func sample_mixture(fs [](func(float64) float64), ps []float64) float64 { + return 1.0 +} + func main() { var n_samples int = 1000000 // var array_samples [n_samples]float64 @@ -57,4 +63,10 @@ func main() { avg = avg / float64(n_samples) fmt.Printf("%v\n", avg) + f1 := func() float64 { + return sample_to(1, 10) + } + + fs := [3](func64){f1, f1, f1} + // x := sample_mixture() }