Christoph_H Posted April 17, 2018 Share Posted April 17, 2018 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. Quote Link to comment Share on other sites More sharing options...
kiryha Posted April 17, 2018 Share Posted April 17, 2018 (edited) 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 April 17, 2018 by kiryha Quote Link to comment Share on other sites More sharing options...
Jesper Rahlff Posted April 17, 2018 Share Posted April 17, 2018 (edited) //pointwrangle float randnum = rand(seed+45,65); //gives value from 0-1, if (randnum <= 0.2) { dont select a point } else if (randnum > 0.2 || <= 0.55) { select 2 points } else if( randnum >0.55) { select 4 points } Edited April 17, 2018 by Jesper Rahlff 1 Quote Link to comment Share on other sites More sharing options...
kiryha Posted April 18, 2018 Share Posted April 18, 2018 Hi, Jesper! Nice setup! How does this command work? rand(@ptnum +45,65) I did not find three arguments example in docs. Cheers! Quote Link to comment Share on other sites More sharing options...
Jesper Rahlff Posted April 18, 2018 Share Posted April 18, 2018 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) Quote Link to comment Share on other sites More sharing options...
Christoph_H Posted April 18, 2018 Author Share Posted April 18, 2018 thank you both 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.