Great package, I'm both new to go, and the challenges of RNG, and I was wondering if you could provide more insight into how to seed this correctly.
It seems like it's fine to seed this independently in a package?
would it better to create multiple instances per goroutine, or per set of go routines?
Using the examples from your tests, its clearly deterministic (which is good)
I'm interested in what step and sequence mean, and how you use them (I'm assuming it has to do with the PCG input and output functions)?
should something other than time.Time(time.Now()).UnixNano() be used in the seed for more "randomness"
I created a working example, in which I managed to generate an even distribution, in a seemingly non-deterministic way, but feel a bit like a monkey bashing the keyboard. (I've included results for a small range below, but have run this with multiple ranges, up to 1m)
package main
import (
"fmt"
"github.com/MichaelTJones/pcg"
"sort"
"time"
)
func main() {
st1 := uint64(time.Time(time.Now()).UnixNano())
st2 := uint64(time.Time(time.Now()).UnixNano()<<32)
rng := pcg.NewPCG64().Seed(st1, st2, 1, 1)
//batch := map[uint64]uint64{}
count := map[uint64]uint64{}
// roll the dice
for i := 100000000; i >= 1; i-- {
num := rng.Bounded(6)+1
count[num] = count[num] + 1
}
// To store the keys in slice in sorted order
var keys []int
for k := range count {
keys = append(keys, int(k))
}
sort.Ints(keys)
for _, k := range keys {
fmt.Printf("counts: %v %v \n", k, count[uint64(k)])
}
}
This seems to produce reasonably good results, but if you could enlighten me with regards to the seed arguments that would be amazing.
Hi Micheal,
Great package, I'm both new to go, and the challenges of RNG, and I was wondering if you could provide more insight into how to seed this correctly.
time.Time(time.Now()).UnixNano()
be used in the seed for more "randomness"I created a working example, in which I managed to generate an even distribution, in a seemingly non-deterministic way, but feel a bit like a monkey bashing the keyboard. (I've included results for a small range below, but have run this with multiple ranges, up to 1m)
This seems to produce reasonably good results, but if you could enlighten me with regards to the seed arguments that would be amazing.