On 25/05/12 09:31, davidw wrote:
Thanks for the answer Jonathan, that totally makes sence.
But I'm more after what actuall randomizer people use. I see here you
refer to the function p_random() as the pseudo random number generator.
Any good example here that's easy to use that generates random enough
numbers that are always the same for the known several parameters I input?
The twister algorithm is quite good, and based on a seed it will always
generate the same numbers (deterministic):
http://en.wikipedia.org/wiki/Mersenne_twister
This is also pretty good, but hasn't got as good a period (distribution):
http://groups.google.com/group/sci.crypt/browse_thread/thread/ca8682a4658a124d/
Keep in mind that using the c rand() function in code that's called a
lot can be dangerous depending on the platform and what you're doing -
on Linux at least, rand() isn't thread-safe, so it internally uses a
mutex lock which is very slow when used in multiple threads as there's a
lot of contention. You can use rand_r() instead which alleviates this.
But it's probably better to just use one of the above algorithms.
Peter
--
Peter Pearson, Software Engineer
The Foundry, 6th Floor, The Communications Building,
48 Leicester Square, London, UK, WC2H 7LT
Tel: +44 (0)20 7434 0449 Web: www.thefoundry.co.uk
The Foundry Visionmongers Ltd.
Registered in England and Wales No: 4642027
_______________________________________________
Nuke-dev mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev