Hi! I'm looking for a randomizer function which I can use to... well, randomize stuff. Do anyone know or have one, please can you kindly post it here. Thanks.
Look at Agner Fog's site: http://www.agner.org/
He has random number generators for:
- Uniform distributions (float, int, binary digits)
- Normal distributions
- Hypergeometric distributions
- Many many other distributions (the ones above are the only ones I've used)
If there is another distribution that you need, wikipedia will usually give you pseudocode to convert from a uniform distribution to whatever you want (e.g. Gamma distribution).
Ossa
Hey thanks. I've been trying to get Agner Frog's Mothera randomizer to work, but its a bit too complicated. Maybe I'm overlooking something. But if you can, can you please send a simple example on how to get the Mothera randomizer working, thank you. I'm running on a tight schedule so its clear why I sound a bit hasty.
There have been many random number generators posted here try searching the forum.
Quote from: Gio on May 14, 2006, 08:42:10 PM
Hey thanks. I've been trying to get Agner Frog's Mothera randomizer to work, but its a bit too complicated. Maybe I'm overlooking something. But if you can, can you please send a simple example on how to get the Mothera randomizer working, thank you. I'm running on a tight schedule so its clear why I sound a bit hasty.
Sorry, I forgot that it doesn't come with an assembly include. Here's the important parts:
1) For Mother-of-all, you will need to define the following:
MRandomInit PROTO C :DWORD
MRandom PROTO C
MIRandom PROTO C :DWORD, :DWORD
MBRandom PROTO C
2) To initialise, pass a seed to the MRandomInit function, for example:
rdtsc
invoke MRandomInit, eax
(remember that you need .586 at the top of your source to be able to use rdtsc)
3) Get random numbers, e.g. for integers (from 0 to 100):
invoke MIRandom, 0, 100
for random bits in eax:
invoke MBRandom
for random floats/doubles between 0 and 1:
invoke MRandom
(note that these are stored on the top of the FPU register stack and can be retrieved using fstp or similar)
--------------------------------------
Thats it! If you have any other questions, I'll be happy to help... attached is a file that contains examples of all of the above.
Ossa
[attachment deleted by admin]
Bah, just decided that in case you want to use some of the other functions, these are the definitions you would need (note that I haven't checked this at all, so mistakes are possible). You will also need to check how the values are returned etc.
; Mersenne Twister
TRandomInit PROTO C :DWORD
TRandomInitByArray PROTO C :DWORD, DWORD ; This line might well be wrong, I didn't bother checking
TRandom PROTO C
TRandom2 PROTO C
TRandom3 PROTO C
TIRandom PROTO C :DWORD, :DWORD
TBRandom PROTO C
; Mother-of-all generator
MRandomInit PROTO C :DWORD
MRandom PROTO C
MIRandom PROTO C :DWORD, :DWORD
MBRandom PROTO C
; RANROT type W generator
WRandomInit PROTO C :DWORD
WRandom PROTO C
WIRandom PROTO C :DWORD, :DWORD
WBRandom PROTO C
; Combined generator
XRandomInit PROTO C :DWORD
XRandom PROTO C
XIRandom PROTO C :DWORD, :DWORD
XBRandom PROTO C
Ossa
http://www.masmforum.com/simple/index.php?topic=3616.msg30071#msg30071
Ossa, thanks in a million!