Jump to page: 1 2
Thread overview
RFC - Mersenne Twister (SFMT)
Nov 17, 2007
Tyro[a.c.edwards]
Nov 17, 2007
Jason House
Nov 17, 2007
Bill Baxter
Nov 18, 2007
Jason House
Nov 17, 2007
BCS
Nov 18, 2007
Tyro[a.c.edwards]
Nov 18, 2007
BCS
Nov 17, 2007
Derek Parnell
Nov 18, 2007
Matti Niemenmaa
Nov 18, 2007
Bill Baxter
Nov 18, 2007
Tyro[a.c.edwards]
November 17, 2007
After reading Julienne Walker's article (http://www.eternallyconfuzzled.com/arts/jsw_art_rand.aspx) on rand() I wondered why the very best psudo-random generator available is not the standard. I looked at the std.random and was not happy to find out that it is slower than I rand() so I attempted to convert Mersenne Twister (again). I'm hoping to get some feedback on how to improve upon the attempt. The actual library (http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/index.html) comes with code for both 64-bit OSes and more.

D version: D v2.007
OS: Windows XP - sp2

Thanks,
Andrew


November 17, 2007
Tyro[a.c.edwards] wrote:

> After reading Julienne Walker's article (http://www.eternallyconfuzzled.com/arts/jsw_art_rand.aspx) on rand() I wondered why the very best psudo-random generator available is not the standard. I looked at the std.random and was not happy to find out that it is slower than I rand() so I attempted to convert Mersenne Twister (again). I'm hoping to get some feedback on how to improve upon the attempt. The actual library (http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/index.html) comes with code for both 64-bit OSes and more.
> 
> D version: D v2.007
> OS: Windows XP - sp2
> 
> Thanks,
> Andrew

I also have a Mersenne Twister implementation available at: http://housebot.svn.sourceforge.net/viewvc/housebot/trunk/housebot/random.d?view=log
November 17, 2007
Reply to tyro[a.c.edwards],

> After reading Julienne Walker's article
> (http://www.eternallyconfuzzled.com/arts/jsw_art_rand.aspx) on rand()
> I wondered why the very best psudo-random generator available is not
> the standard. I looked at the std.random and was not happy to find out
> that it is slower than I rand() so I attempted to convert Mersenne
> Twister (again). I'm hoping to get some feedback on how to improve
> upon the attempt. The actual library
> (http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/index.html)
> comes with code for both 64-bit OSes and more.
> 
> D version: D v2.007
> OS: Windows XP - sp2
> Thanks,
> Andrew

If you want svn hosting for this you can put it in scrapple:

http://www.dsource.org/projects/scrapple/

If you don't have access, send me a username and I'll add you.


November 17, 2007
Jason House wrote:
> Tyro[a.c.edwards] wrote:
> 
>> After reading Julienne Walker's article
>> (http://www.eternallyconfuzzled.com/arts/jsw_art_rand.aspx) on rand() I
>> wondered why the very best psudo-random generator available is not the
>> standard. I looked at the std.random and was not happy to find out that it
>> is slower than I rand() so I attempted to convert Mersenne Twister
>> (again). I'm hoping to get some feedback on how to improve upon the
>> attempt. The actual library
>> (http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/index.html) comes
>> with code for both 64-bit OSes and more.
>>
>> D version: D v2.007
>> OS: Windows XP - sp2
>>
>> Thanks,
>> Andrew
> 
> I also have a Mersenne Twister implementation available at:
> http://housebot.svn.sourceforge.net/viewvc/housebot/trunk/housebot/random.d?view=log

Note: Jason's is GPLv3.

--bb
November 17, 2007
LOL ... I did a port to D about a year or so ago, to help teach myself the language. I'll try to dig it out for comparision. I remember adding some extra functions and also allowing for additional entropy to be included.

-- 
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell
November 18, 2007
Bill Baxter wrote:
> Note: Jason's is GPLv3.

... Covering 5 lines of code + imports + unit tests...
The bulk of the code has a looser license.

If someone wants to use it as part of D, I can (and will)
get permission to remove the GPLv3 license.
November 18, 2007
Derek Parnell wrote:
> LOL ... I did a port to D about a year or so ago, to help teach myself the language. I'll try to dig it out for comparision. I remember adding some extra functions and also allowing for additional entropy to be included.

You ported MT19937, which is a bit different from the SFMT that Tyro ported. I've got the code (see attachment), but the original main function is missing.

There's also Wang Zhen's port, which provides a Random class: http://lists.puremagic.com/pipermail/digitalmars-d-announce/2006-April/000816.html

-- 
E-mail address: matti.niemenmaa+news, domain is iki (DOT) fi


November 18, 2007
Tyro[a.c.edwards] wrote:
> After reading Julienne Walker's article (http://www.eternallyconfuzzled.com/arts/jsw_art_rand.aspx) on rand() I wondered why the very best psudo-random generator available is not the standard. I looked at the std.random and was not happy to find out that it is slower than I rand() so I attempted to convert Mersenne Twister (again). I'm hoping to get some feedback on how to improve upon the attempt. The actual library (http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/index.html) comes with code for both 64-bit OSes and more.
> 
> D version: D v2.007
> OS: Windows XP - sp2
> 
> Thanks,
> Andrew

It looks nice.

Not sure what kind of feedback you were after, but I get the feeling that there are a lot of functions there for internal use only.  Those should probably be flagged private to help make it clearer what the actual user interface is.

Also it's nice to give it a module declaration with a doc comment before that that explains what the module is for and the basics of how to use it.

You might also want to provide a class version of the algorithm which encapsulates the state, to make thread safety easier.  But it's nice to retain the  global-state function-based version, since it's a little easier to work with when you don't actually need thread safety.

If that's not the kind of feedback you were after then my apologies.

--bb
November 18, 2007
BCS さんは書きました:
> Reply to tyro[a.c.edwards],
> 
>> After reading Julienne Walker's article
>> (http://www.eternallyconfuzzled.com/arts/jsw_art_rand.aspx) on rand()
>> I wondered why the very best psudo-random generator available is not
>> the standard. I looked at the std.random and was not happy to find out
>> that it is slower than I rand() so I attempted to convert Mersenne
>> Twister (again). I'm hoping to get some feedback on how to improve
>> upon the attempt. The actual library
>> (http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/index.html)
>> comes with code for both 64-bit OSes and more.
>>
>> D version: D v2.007
>> OS: Windows XP - sp2
>> Thanks,
>> Andrew
> 
> If you want svn hosting for this you can put it in scrapple:
> 
> http://www.dsource.org/projects/scrapple/
> 
> If you don't have access, send me a username and I'll add you.
> 
> 
Much appreciated. My user name is tyro.
November 18, 2007
Bill Baxter さんは書きました:
> Tyro[a.c.edwards] wrote:
>> After reading Julienne Walker's article (http://www.eternallyconfuzzled.com/arts/jsw_art_rand.aspx) on rand() I wondered why the very best psudo-random generator available is not the standard. I looked at the std.random and was not happy to find out that it is slower than I rand() so I attempted to convert Mersenne Twister (again). I'm hoping to get some feedback on how to improve upon the attempt. The actual library (http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/index.html) comes with code for both 64-bit OSes and more.
>>
>> D version: D v2.007
>> OS: Windows XP - sp2
>>
>> Thanks,
>> Andrew
> 
> It looks nice.
> 
> Not sure what kind of feedback you were after, but I get the feeling that there are a lot of functions there for internal use only.  Those should probably be flagged private to help make it clearer what the actual user interface is.
> 
> Also it's nice to give it a module declaration with a doc comment before that that explains what the module is for and the basics of how to use it.
> 
> You might also want to provide a class version of the algorithm which encapsulates the state, to make thread safety easier.  But it's nice to retain the  global-state function-based version, since it's a little easier to work with when you don't actually need thread safety.
> 
> If that's not the kind of feedback you were after then my apologies.
> 
> --bb

Thanks --bb, in posting this, I'm was hoping for anyting advice I could get towards improving it and probably so help with the 64bit portion. This qualifies as advice and I'm very greatful.

Andrew
« First   ‹ Prev
1 2