Added random number generator to shuffling of values#41
Merged
wschin merged 1 commit intocjlin1:masterfrom May 12, 2020
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a random number generator to the shuffling of values in the random map generation process. This PR also uses
void shuffle(_RanIt _First, _RanIt _Last, _Urng&& _Func)instead ofvoid random_shuffle(_RanIt _First, _RanIt _Last)to be able to use the RNG.The function
void random_shuffle(_RanIt _First, _RanIt _Last)is implemented differently on different platforms. I found this problem while working on ML .NET, where one of our matrix factorization unit tests produced varying results when run consecutively on MacOS. This variance led to these functions, where the seed variable ofrand()is set through asrand(0):libmf/mf.cpp
Lines 1115 to 1123 in e70b9a3
libmf/mf.cpp
Lines 4070 to 4123 in e70b9a3
This
srand(0)command withvoid random_shuffle(_RanIt _First, _RanIt _Last)does not seem to be producing reliable consecutive results on MacOS. By usingvoid shuffle(_RanIt _First, _RanIt _Last, _Urng&& _Func)and providing an appropriate random number generator, consistent results can be obtained on varying builds.