sant0s81 Posted June 8, 2020 Share Posted June 8, 2020 (edited) Hi, fit01(rand(detail("../foreach_begin1_metadata1/", iteration, 0 )+seed),1,53) gives me a random number between 1 till 53. But what do I have to use, if I want instead of a random number between 1 and 53 a random number of given numbers? Something like '1,2,3,4,5,10,15,45,70,71,72,85, etc...' and than randomize them? Thanks Edited June 8, 2020 by sant0s81 Quote Link to comment Share on other sites More sharing options...
Aizatulin Posted June 8, 2020 Share Posted June 8, 2020 Hi, you can define an array, which contains all number you want generate. Now fit a 0-1 random float value to (0,len(array)) and use the truncated value as index for the array. random_array.hipnc 1 Quote Link to comment Share on other sites More sharing options...
Noobini Posted June 9, 2020 Share Posted June 9, 2020 here's my read of the question, given a bunch of ints....randomize their order. I've implemented the Fisher Yates Shuffle. The detail attribute is so you can see it in geo spreadsheet, is all, it could just be simple temporary array in some wrangle vu_FisherYateShuffle.hiplc 1 Quote Link to comment Share on other sites More sharing options...
Noobini Posted June 9, 2020 Share Posted June 9, 2020 (edited) with seed. also spotted an error, the j should mult with i not max !!! vu_FisherYateShuffle2.hiplc Edited June 9, 2020 by Noobini 1 Quote Link to comment Share on other sites More sharing options...
sant0s81 Posted June 13, 2020 Author Share Posted June 13, 2020 @Aizatulin and @Noobini thank you, some great examples again! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.