3 ms·
How does rand get faster? I would think rand would be so well explored that all mature languages reuse the same implementation. Is it written in C or assembly,
by daxfohl 6y ago
How does rand get faster? I would think rand would be so well explored that all mature languages reuse the same implementation. Is it written in C or assembly, or does it ccall, or is it written in Julia itself?
- coliveira 6y agoI don't know Julia's implementation, but random number generation is far from being standard across languages. There are several algorithms with their own pros/cons, and as architectures change, so change the requirements on good random number generators.
- hellofunk 6y ago> I would think rand would be so well explored On the contrary, random number generation has no general solution and remains an active area of research in many fields that depend on it.
- pletnes 6y agoAlso, different use cases put focus on different quality measures - period, correlations between each generated number, performance... there is room for many useful algorithms.
- igg 6y agoIt is Julia all the way down. julia> @which randn(1000) randn(dims::Integer...) in Random at ~/Software/Julia/share/julia/stdlib/v1.5/Random/src/normal.jl:210 julia> @edit randn(1000) # Opens the normal.jl file in your editor julia> @run randn(1000) # Starts the debugger in VSCode Digging deeper, at least one of the PRs [1] is based on a 2018 paper [2] [1] https://github.com/JuliaLang/julia/pull/29240 https://github.com/JuliaLang/julia/pull/29240 [2] https://arxiv.org/abs/1805.10941 https://arxiv.org/abs/1805.10941