Jump to content

Choose Randomly with even distribution


Recommended Posts

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...