Re: [go-nuts] efficient random float32 number generator?

2019-03-05 Thread Damian Gryski
On Monday, February 25, 2019 at 2:39:02 PM UTC-8, DrGo wrote: > > Thanks Ian, > The std lib float32 is slow for my purpose. In my benchmarking it is > actually slower than the float64. But I don’t even need float16 precision. > I am working on implementing othe alias method for sampling from

Re: [go-nuts] efficient random float32 number generator?

2019-03-03 Thread DrGo
For future reference: After trying different solutions (some are described in the above posts), the most performant solution was based on Michael Jones' pcg package ( https://github.com/MichaelTJones/pcg) with a tweaked Bound() function (to use an algorithm similar to Go's std lib). Using Go

Re: [go-nuts] efficient random float32 number generator?

2019-02-26 Thread Ian Denhardt
Quoting Marvin Renich (2019-02-26 07:11:47) > * Louki Sumirniy [190226 06:22]: > > Assuming there is bytes in the system's entropy pool, you can also skip the > > scrambling step, though I don't know what overhead consuming these bytes > > entails compared to a standard PRNG. Then the biggest

Re: [go-nuts] efficient random float32 number generator?

2019-02-26 Thread DrGo
nice speedup using https://github.com/MichaelTJones/pcg ## using stdlb math/rand (Go 1.11.5) pkg: github.com/drgo/abm/rng BenchmarkScalingFreqDistributionSampler/n-levels=2-12

Re: [go-nuts] efficient random float32 number generator?

2019-02-26 Thread DrGo
Thanks everyone for helpful feedback, What do people think about the approach explained here http://iquilezles.org/www/articles/sfrand/sfrand.htm? Any possible disadvantages in a Go implementation? -- You received this message because you are subscribed to the Google Groups "golang-nuts"

Re: [go-nuts] efficient random float32 number generator?

2019-02-26 Thread Marvin Renich
* Louki Sumirniy [190226 06:22]: > Assuming there is bytes in the system's entropy pool, you can also skip the > scrambling step, though I don't know what overhead consuming these bytes > entails compared to a standard PRNG. Then the biggest part of it is making > the raw bytes into float. I'm

Re: [go-nuts] efficient random float32 number generator?

2019-02-26 Thread Louki Sumirniy
Assuming there is bytes in the system's entropy pool, you can also skip the scrambling step, though I don't know what overhead consuming these bytes entails compared to a standard PRNG. Then the biggest part of it is making the raw bytes into float. I'm not sure - could you take 4 random bytes,

Re: [go-nuts] efficient random float32 number generator?

2019-02-25 Thread Michael Jones
My instinct (for "please invent for me the fastest possible low fidelity floating point prng algorithm") is to look at RC4 for inspiration, permuting the order of a large table of float32s and constantly modifying them as well. This could be pared down to three index accesses, a floating

Re: [go-nuts] efficient random float32 number generator?

2019-02-25 Thread Michael Jones
My PCG library's 32-bit generator generates a 32-bit pseudo-random integer in 2.23 ns. https://github.com/MichaelTJones/pcg Just wrote this 32-bit float extension and that delivers a float32 in 2.75 ns. (363 million/good values/sec, period of 2**64 = 4 billion). The extra time is for the

Re: [go-nuts] efficient random float32 number generator?

2019-02-25 Thread Rob Pike
If you don't need precision, just generate ints and scale them. -rob On Tue, Feb 26, 2019 at 9:39 AM DrGo wrote: > Thanks Ian, > The std lib float32 is slow for my purpose. In my benchmarking it is > actually slower than the float64. But I don’t even need float16 precision. > I am working on

Re: [go-nuts] efficient random float32 number generator?

2019-02-25 Thread DrGo
Thanks Ian, The std lib float32 is slow for my purpose. In my benchmarking it is actually slower than the float64. But I don’t even need float16 precision. I am working on implementing othe alias method for sampling from a fixed freq dist with possibly thousands of arbitrary values. So the rng

Re: [go-nuts] efficient random float32 number generator?

2019-02-25 Thread Ian Lance Taylor
On Mon, Feb 25, 2019 at 2:01 PM DrGo wrote: > > what is the fastest possible algorithm to generate a float32 pseudo-random > number in [0.0,1.0)? > need to generate billions of numbers. Statistical performance and security > (and even space) are not a priority. > any Go implementations you know