Mersenne Twister implentation
|
02-04-2017, 04:19 PM
Post: #1
|
|||
|
|||
Mersenne Twister implentation
Based on the discussion in the random number thread, here is an implementation of the Mersenne Twister.
To use, call Twister which will set up the state in the list L9(). I used a list instead of a matrix since a list can store integers. After the initial Setup you can call: MTSEED(number) to reset the seed. RANDMT() to get a uniform number from 0 to 1 RANDMTI() to get the raw hex numbers RANDMTN() to get normally distributed numbers with a mean of 0 and SD of 1. Observations: The output matches the reference implementations exactly. Bit twiddling is not the Prime's strong suit. (Dogs walking on their hind legs come to mind) It is much slower than the built in functions. My random pi program is slowed down by a factor of about 20, 21.5 sec for 10000 iterations vs 1.2 sec for 10000 iterations using the built-in rand. Code:
|
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Mersenne Twister implentation - KeithB - 02-04-2017 04:19 PM
RE: Mersenne Twister implentation - grsbanks - 02-05-2017, 05:37 PM
RE: Mersenne Twister implentation - rprosperi - 02-05-2017, 07:00 PM
RE: Mersenne Twister implentation - grsbanks - 02-05-2017, 09:53 PM
RE: Mersenne Twister implentation - grsbanks - 02-06-2017, 07:58 AM
RE: Mersenne Twister implentation - rprosperi - 02-06-2017, 11:23 PM
RE: Mersenne Twister implentation - KeithB - 02-06-2017, 04:42 PM
RE: Mersenne Twister implentation - grsbanks - 02-06-2017, 06:24 PM
RE: Mersenne Twister implentation - KeithB - 02-06-2017, 07:08 PM
RE: Mersenne Twister implentation - Tim Wessman - 02-06-2017, 10:18 PM
RE: Mersenne Twister implentation - grsbanks - 02-07-2017, 08:24 AM
|
User(s) browsing this thread: 2 Guest(s)