Code covered by the BSD License  

5.0

5.0 | 3 ratings Rate this file 25 Downloads (last 30 days) File Size: 6.06 KB File ID: #6614

Mersenne Twister

by

 

23 Dec 2004 (Updated )

Mersenne Twister uniform pseudo-random number generator.

| Watch this File

File Information
Description

NOTE: Beginning in V7.1 (R14SP3), MATLABĀ® includes built-in support for the Mersenne Twister. The mex file here is only needed for versions prior to that.

TWISTER produces pseudo-random numbers using the Mersenne Twister algorithm by Nishimura and Matsumoto, and is an alternative to the built-in function RAND in MATLAB. It creates double precision values in the closed interval [0, 1-2^(-53)], and can generate 2^19937 - 1 values before repeating itself.

This is a Mex file implementation derived from a copyrighted C program by Takuji Nishimura and Makoto Matsumoto. See, e.g., http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html

Reference: M. Matsumoto and T. Nishimura, "Mersenne Twister: A 623-Dimensionally Equidistributed Uniform Pseudo-Random Number Generator", ACM Transactions on Modeling and Computer Simulation, Vol. 8, No. 1, January 1998, pp 3--30.

MATLAB release MATLAB 7 (R14)
Other requirements To build object code for any platform, type "mex twister.cpp".
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (5)
06 Aug 2009 James Tursa

To Joe Bunda: The included lcc is a C compiler, not a C++ compiler. You need a C++ compiler to compile twister.cpp. I did a quick look at the code and it looks like it wouldn't take much to convert it to a C routine that lcc would accept.

To Peter Perkins: Do you plan on including a C version in a later update for people without a C++ compiler? If not, would you mind if I made a go at it?

02 Nov 2006 Giuppy iuppie

it works for me.
Thanks so much

27 Jul 2006 Joe Bunda

I am using Matlab R2006a in Windows XP x64. When I issue the "mex twister.cpp" command, I receive an error message

Error: Could not detect a compiler on local system which can compile the specified input file(s) at C:\Program files\MATLAB\R2006a/bin
/mexsetup.pm line 540.

I did check the installation to verify that the LCC compiler is installed

22 Mar 2005 Kent Conover

It worked the first time in R14. By my test twister is significantly faster, it requires only 60% of the runtime taken by the Matlab m-file rand();

04 Feb 2005 Steven A.

Thanks for providing this. While the built-in random number generator is more then adequate, this is a great addition for a few reasons. 1. It shows the power of MEX! Very cool indeed. 2. Shows how the Mathworks is on the bleeding edge of technology!

Updates
02 Jun 2009

Removed binaries.

12 Jun 2009

Cleaned up file header information.

18 Jun 2009

Add copyright.

06 Aug 2009

Copyrights.

Contact us