5.0

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

Mersenne Twister

by Peter Perkins

 

23 Dec 2004 (Updated 06 Aug 2009)

Code covered by the BSD License  

Mersenne Twister uniform pseudo-random number generator.

Download Now | 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".
Zip File Content  
Other Files license.txt,
twister.cpp
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
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!

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();

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

02 Nov 2006 Giuppy iuppie

it works for me.
Thanks so much

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?

Please login to add a comment or rating.
Updates
03 Jan 2005

Added authorship notice.

02 Jun 2009

Removed binaries.

12 Jun 2009

Cleaned up file header information.

18 Jun 2009

Add copyright.

06 Aug 2009

Copyrights.

Tag Activity for this File
Tag Applied By Date/Time
statistics Peter Perkins 22 Oct 2008 07:38:43
probability Peter Perkins 22 Oct 2008 07:38:43
random number Peter Perkins 22 Oct 2008 07:38:43
generator Peter Perkins 22 Oct 2008 07:38:43
mersenne Peter Perkins 22 Oct 2008 07:38:43
twister Peter Perkins 22 Oct 2008 07:38:43
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com