one is different from rand . when using one(AbstractFloat) all outputs are "the same":
julia> one(Float64) 1.0 julia> one(Float32) 1.0f0 julia> 1.0 == 1.0f0 true
this is not true when using rand :
julia> rand(srand(1), Float64) 0.23603334566204692 julia> rand(srand(1), Float32) 0.5479944f0 julia> rand(srand(1), Float32) == rand(srand(1), Float64) false
this means that if rand behaves like one , you can get two different results with the same seed on two different machines (for example, one is x86, the other is x64). take a look at the code in random.jl :
@inline rand {T <: Union {Bool, Int8, UInt8, Int16, UInt16, Int32, UInt32}} (r :: MersenneTwister, :: Type {T}) = rand_ui52_raw (r)% T
both rand(Signed) & rand(Unsigned) are also illegal.
source share