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 multiply: func (p *PCG32) Float32() float32 { const bits = 23 const denom = 1.0 / float32(1<<bits) return float32(p.Random()>>(32-bits)) * denom } The same thing, but with the 2**128 period generator is 6.91 ns/op per float32 If you want faster than that then you'll need to look at other ways, likely non-multiply ways. IMPORTANT... Also, be reminded that generating "random real values in [0..1)" is not the same thing as "random floating point values in [0..1)". it is subtle, and it seems you may want the former, but a random sampling of float32's in that range would be different, using the exponent to scale the 8 million possible mantissa fractions to various tiny ranges. There are 4 billion values total. so som big subsetting is happening. On Mon, Feb 25, 2019 at 2:05 PM Ian Lance Taylor <i...@golang.org> wrote: > On Mon, Feb 25, 2019 at 2:01 PM DrGo <salah.mah...@gmail.com> 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 of? > > Take a look at https://godoc.org/golang.org/x/exp/rand . > > Ian > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- *Michael T. jonesmichael.jo...@gmail.com <michael.jo...@gmail.com>* -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.