magneto Posted March 4, 2012 Share Posted March 4, 2012 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 Quote Link to comment Share on other sites More sharing options...
symek Posted March 4, 2012 Share Posted March 4, 2012 (edited) x = rand($PT) y = rand($PT+0.1) ... more likely Also from Help: NoteIt is a good idea to use non-integer values as the argument to rand(). Edited March 4, 2012 by SYmek 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted March 4, 2012 Author Share Posted March 4, 2012 Thanks Symek. I read that but didn't realize that's what it exactly meant till you pointed out. Quote Link to comment Share on other sites More sharing options...
thinkinmonkey Posted March 4, 2012 Share Posted March 4, 2012 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 ), 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. 1 Quote Link to comment Share on other sites More sharing options...
hopbin9 Posted March 4, 2012 Share Posted March 4, 2012 (edited) I think these formulas over complicate it. If X is already a random value, then you already have the seed for the next random value. x = rand($PT) y = rand(x) z = rand(y) Edited March 4, 2012 by hopbin9 2 Quote Link to comment Share on other sites More sharing options...
thinkinmonkey Posted March 4, 2012 Share Posted March 4, 2012 Hopbin9, YOU WIN! Taking notes... 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted March 4, 2012 Author Share Posted March 4, 2012 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. Quote Link to comment Share on other sites More sharing options...
thinkinmonkey Posted March 4, 2012 Share Posted March 4, 2012 @thinkingmonkey, when you stared talking about diamond shapes, I thought you were trolling Well, I didn't know how else to describe that! But I didn't realize the non-integer advantage for the rand expression. Never used integer with rand() in H. Quote Link to comment Share on other sites More sharing options...
hopbin9 Posted March 4, 2012 Share Posted March 4, 2012 rand($PT * 13) rand($PT * 17) rand($PT * 19) Clever. I like it 1 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.