Jump to content

Best way to offset the randomization of values


Recommended Posts

When generating random values for different parameters using the rand expression, I see people multiplying the result with a value, or adding a value to the result, etc.

Which way is the most preferred way that gives the most chaotic results?

Is it enough to just do something like?

x = rand($PT)

y = rand($PT) + 1

z = rand($PT) + 2

I feel this will not provide as much difference for instance.

What are the best practices?

I am sure Houdini experts would have their consistent methods they always use regardless.

Thanks :)

Link to comment
Share on other sites

Magneto,

what SYmek suggested is right. You have to remember that random doesn't mean a casual number, but if you give the same seed to the function, you'll obtain the same result:

rand(5) = rand(5)

Now my formulas normally use big numbers for the seed, float numbers as SYmek says, and I use a little trick, let's say, to remember those numbers, in order to change always seeds:

My formulas are something like this:

x = rand($PT*159.357+741.23)
y = rand($PT*951.753+486.624)
z = rand($PT*426.684+123.654)

If you try to digit the above numbers on your numpad, you'll see soon they are numbers taken following diagonals (951.753, 159.357), "L" shapes (741.23), "Diamond" shapes (426.684), "dumb" shape (123.456 :D), etc.

It's like a "finger ballet", in this way I (should ;)) know to not use that kind of shape for next combinations or, if I'm in trouble, I simply copy/paste the previous formulas in different order, for example using the previous one, it will be:

x = rand($PT*741.23+159.357)
y = rand($PT*486.624+951.753)
z = rand($PT*123.654+426.684)

And don't forget that rand() gives you always values ranging in [0..1], so I quite often use it with fit01() function to control it better according to my needs.

Cheers.

  • Like 1
Link to comment
Share on other sites

Thanks for the input guys. This is all interesting.

@thinkingmonkey, when you stared talking about diamond shapes, I thought you were trolling :)

What about using prime numbers though? From what I know that's a good way to offset randomization in general programming. Something like:

rand($PT * 13)

rand($PT * 17)

rand($PT * 19)

But I didn't realize the non-integer advantage for the rand expression.

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