Jump to content

Random with percentage probabilities for different results


Christoph_H

Recommended Posts

I have problems for the following configuration:
I tried to use an If Loop in the wrangler to add certain percentage probabilities.
I failed, however.

In this case:
a 20 percent probability that he does not select a point.

a 35 percent probability that he selects 2 points.

a 45% probability that he selects 4 points.

The whole thing would have to be subject to a random function with seed.
So far I have the impression that I would have to combine several random functions.
I have no idea how to do this. I also searched the Internet, but found nothing that would have helped me.

Thanks again for your help.

Link to comment
Share on other sites

I took the first brute force idea from this topic and implement it with VEX. Connect Attribute wrangle node to a geometry and check @show attribute in Geometry Spreadsheet:

float rand = rint(rand(@ptnum)*10);
int porbMap[] = {0,0,2,2,2,4,4,4,4,4};
int randMapped = porbMap[rand];
s@show = sprintf('%s', randMapped);

the probMap is an array where you define your conditions. I reduce array size from 100 to 10, so instead of  20 zeros for 20% probability of selecting zero points, you need to enter only 2 (30% probability to select 2 points and 50% probability to select 4 points).
Its awful algorithm and I am not 100% sure If it's working correctly. Certainly, there should be a more elegant solution!

Edited by kiryha
Link to comment
Share on other sites

35 minutes ago, kiryha said:

Hi, Jesper! Nice setup!
How does this command work?


rand(@ptnum +45,65)

I did not find three arguments example in docs.
Cheers!

actually it is just the regular rand() function with one argument. I just added to that one value argument. so rand(@ptnum + 45.65 + @seed), all turn into one value. (I realize in my previous post I used komma , instead of dot to declare the decimal. its an old European habbit and is wrong. the number should be 45.65) 

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...