philpappas Posted October 6, 2019 Share Posted October 6, 2019 I have this expression to choose from a set of numbers randomly. (1,2,3,4,5,6....49,50) floor(rand($PT*ch("seed"))*detail("../node/","total",0)) My problem is that out of 50 numbers that i have only 23 make it after the expression. How can i make sure every number gets picked? Quote Link to comment Share on other sites More sharing options...
Atom Posted October 6, 2019 Share Posted October 6, 2019 I don't think I would use a floor for that. Maybe try... int rnd_index = int(fit01(rand(@ptnum+ch("seed")),1,50)); The nature of random numbers is that you might not get all 50 variation, while processing 50 points. To achieve that consider randomizing a list/array and using the point number as an index into that list. https://www.sidefx.com/forum/topic/52579/?page=1#post-236406 Quote Link to comment Share on other sites More sharing options...
ThomasPara Posted October 7, 2019 Share Posted October 7, 2019 i guess int is rounding to nearest integer, while floor will allways go down. //floor i@rnd_value = int(floor(rand((@ptnum+1)*(chi("seed")+1))*chi("range")))+1; //rint i@rnd_value = int(rint(rand((@ptnum+1)*(chi("seed")+1))*chi("range")))+1; Quote Link to comment Share on other sites More sharing options...
philpappas Posted October 7, 2019 Author Share Posted October 7, 2019 thanks a lot for the pointers! i will try both when i find time and get back to you 22 hours ago, Atom said: To achieve that consider randomizing a list/array and using the point number as an index into that list. that is actually a very good idea 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.