From friedrich.leisch at stat.uni-muenchen.de  Thu May 14 09:33:08 2009
From: friedrich.leisch at stat.uni-muenchen.de (Friedrich Leisch)
Date: Thu, 14 May 2009 09:33:08 +0200
Subject: [Rd] different results on linux and windows
In-Reply-To: <4A094FBD.3080709@uta.fi>
References: <4A094FBD.3080709@uta.fi>
Message-ID: <18955.51508.342442.705944@lxh5.stat.uni-muenchen.de>

>>>>> On Tue, 12 May 2009 13:30:21 +0300,
>>>>> Klaus Nordhausen (KN) wrote:

  > Dear R experts,
  > we are preparing an R-package to compute the Oja Median which contains
  > some C++ code in which random numbers are needed. To generate the random
  > numbers we use the following Mersenne-Twister implementation:

  > // MersenneTwister.h
  > // Mersenne Twister random number generator -- a C++ class MTRand
  > // Based on code by Makoto Matsumoto, Takuji Nishimura, and Shawn Cokus
  > // Richard J. Wagner  v1.0  15 May 2003  rjwagner at writeme.com

  > the random seed for the Mersenne-Twister is provided by our R-function
  > which gives an (random) integer to  the C++ function srand() which in
  > turn sets the seed in the code.

  > Using the set.seed in R makes now the results reproducible, but the
  > results differ between windows and linux.

  > Does anyone know what the problem there is?

[...]

I cannot directly help with the problem, but one quick question: Why
do you ship your own random number generator rather than use the one
that ships with R (which by default is Mersenne Twister anyway)? The
API is documented in "Writing R Extensions".

The advantage in using R's RNG is that the user can change it, e.g.,
to take care of streams for parallel processing on clusters etc

Best,
Fritz

-- 
-----------------------------------------------------------------------
Prof. Dr. Friedrich Leisch 

Institut f?r Statistik                          Tel: (+49 89) 2180 3165
Ludwig-Maximilians-Universit?t                  Fax: (+49 89) 2180 5308
Ludwigstra?e 33
D-80539 M?nchen                     http://www.statistik.lmu.de/~leisch
-----------------------------------------------------------------------
   Journal Computational Statistics --- http://www.springer.com/180 
          M?nchner R Kurse --- http://www.statistik.lmu.de/R



[Rd] different results on linux and windows
Friedrich Leisch