Based on this issue, https://github.com/JuliaLang/julia/issues/8606, I see we are generating different random number sequence in Julia and MATLAB. Is their a way to get same random numbers in both languages ? I see a comment ‘you can get that by implementing the same RNG as matlab/python in Julia in a package, but not in Base.’ and I am not sure how exactly to do that
For example, if i want to benchmark some sorting algorithms in different languages, i would start with same initial data-set. Other option is to use a fixed data-set (hard-coded).
I would suggest generating the test data in one language or the other and saving it as a .mat file (you can use MAT.jl to read mat files in Julia). That will give you reliably identical data which you can also save for posterity if you want.
Alternatively, if it is feasible to test your sorting algorithm on thousands of randomly generated datasets, the average performance should be robust to the composition of your data.
Thank you all. I ended up using (rdeits suggestion)
“I would suggest generating the test data in one language or the other and saving it as a .mat file (you can use MAT.jl to read mat files in Julia). That will give you reliably identical data which you can also save for posterity if you want.”
I wonder if someone has made any progress on this. I have a similar issue to @rohith14 and found my way using @rdeits suggestion.
I am estimating a simple optimization algorithm using Julia’s optimize(..., NelderMead()) from the package ‘Optim.jl’ and MATLAB’s fminsearch().
The estimation involves simulating random draws. The seed in Julia is through Random.seed!() from Random.jl whereas in MATLAB is set using rand('state',...).
However, the only way to get results in Julia that are close to what I get in MATLAB is by importing the simulated data from MATLAB (through MAT.jl).
Does anyone know if it is possible to get the same random numbers in both languages?
The Xoshiro-family pseudorandom generators are straightforward to implement, if you don’t need maximum performance. This is the reference implementation for xoshiro256++:
So I guess you just need to implement it in Matlab, given that Julia comes with it in the Random stdlib. Start with the same seed in Julia and Matlab, of course.