Chances of random number based on ramp

   2084   3   0
User Avatar
Member
900 posts
Joined: 2月 2016
Offline
There's the attribute randomize node that provides the “ramp distribution method”. But it's quite counter intuitive to use in my opinion.
Take these two attribute randomize nodes for example: these two ramps would output the same random values with the same chances, right?



Ideally I'd like to have a ramp distribution that works the other way round, where the X axis represents the random values it can output(0-1), and Y axis is the chance of these values to be picked.
So in the following example, my ideal ramp would output with high chances values close to 1. And zero chances for values less than 0.5



Do you have any idea how to accomplish it?
How to modulate a random generator with a function (a ramp)?
Edited by Andr - 2019年1月29日 15:52:20
User Avatar
Member
480 posts
Joined: 7月 2005
Offline
Hi,

I think the reason is, that the custom ramp is expecting the inverse of the (cumulative) distribution function and not the density function itself. If you have a uniform distributed sample (from 0 to 1) you can apply the inverse of any strict increasing distribution. After you applied the function, your sample will have the distribution, from the inverse you applied.
Note that the inverse should be also increasing.
Here is an example of points, which are distributed on a curve using an u-parameter. In comparison I used both methods and the results looks similar but not equal. This depends on the way, how the parameters are calculated.
If you play around with the ramp values, you can see, how the density of the points (on the curve) is changing depending on the slope.

Attachments:
uniform_to_custom_dist.hipnc (106.9 KB)

User Avatar
Member
900 posts
Joined: 2月 2016
Offline
hey Aizatulin, thanks for the effort, I don't know if I fully understand what you are trying to achieve there, anyway thanks to your words I came up with a solution. The keyword was density.
It was just a matter of using a ramp to drive the density of a scatter node, which scatter points on a line of length 1.
Then I can just pick @P.x for every point to have my random generated value, based on density.
Dumb me, it was so easy.
Thanks again!! cheers
User Avatar
Member
480 posts
Joined: 7月 2005
Offline
Sure and sorry, because my example was a bit misleading. The way you are describing is good for using a density function. But make sure, that your geometry has a satisfying resolution, or the distributed values will become inaccurate.
My example was more related to describe the custom ramp of the attribute randomize node. The main difference is, that you don't need highly subdivided geometry, but you have to work with (inverted cumulative) distribution function. Another point is, that the scatter node can use 2D/3D-density aswell.
Edited by Aizatulin - 2019年2月2日 03:26:34
  • Quick Links