From help-request at octave dot org Sun Feb 6 10:31:33 2005 Subject: Re: randn newbie question From: Paul Kienzle To: Hamish Allan Cc: help at octave dot org Date: Sun, 6 Feb 2005 11:36:29 -0500 --Apple-Mail-1-551570306 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed On Feb 5, 2005, at 11:55 AM, Hamish Allan wrote: > Why does: > > plot(randn(2,100)', '+') > > which looks like this in Matlab: > > http://igor.gold.ac.uk/~map01ra/matlab_randn.jpeg > > look like this in Octave: > > http://igor.gold.ac.uk/~map01ra/octave_randn.jpeg > > ??? The reason is that I messed up the test for X86 architecture in randmtzig.c, and you are compiling little endian rather than big endian architecture. I've fixed this in CVS. Before making a new release, I want to put some distributional tests around the random number generator code so nothing so egregious happens again. Please try the attached patch. - Paul --Apple-Mail-1-551570306 Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0644; name="randmt.patch" Content-Disposition: attachment; filename=randmt.patch Index: randmtzig.c =================================================================== RCS file: /cvsroot/octave/octave-forge/FIXES/randmtzig.c,v retrieving revision 1.9 retrieving revision 1.10 diff -c -p -r1.9 -r1.10 *** randmtzig.c 8 Nov 2004 11:41:25 -0000 1.9 --- randmtzig.c 6 Feb 2005 16:19:28 -0000 1.10 *************** USE_INLINE uint64_t randi53(void) *** 335,341 **** { const uint32_t lo = randi32(); const uint32_t hi = randi32()&0x1FFFFF; ! #if defined(HAVE_X86) uint64_t u; uint32_t *p = (uint32_t *)&u; p[0] = lo; --- 335,341 ---- { const uint32_t lo = randi32(); const uint32_t hi = randi32()&0x1FFFFF; ! #if HAVE_X86 uint64_t u; uint32_t *p = (uint32_t *)&u; p[0] = lo; *************** USE_INLINE uint64_t randi54(void) *** 350,356 **** { const uint32_t lo = randi32(); const uint32_t hi = randi32()&0x3FFFFF; ! #if defined(HAVE_X86) uint64_t u; uint32_t *p = (uint32_t *)&u; p[0] = lo; --- 350,356 ---- { const uint32_t lo = randi32(); const uint32_t hi = randi32()&0x3FFFFF; ! #if HAVE_X86 uint64_t u; uint32_t *p = (uint32_t *)&u; p[0] = lo; *************** USE_INLINE uint64_t randi64(void) *** 365,371 **** { const uint32_t lo = randi32(); const uint32_t hi = randi32(); ! #if defined(HAVE_X86) uint64_t u; uint32_t *p = (uint32_t *)&u; p[0] = lo; --- 365,371 ---- { const uint32_t lo = randi32(); const uint32_t hi = randi32(); ! #if HAVE_X86 uint64_t u; uint32_t *p = (uint32_t *)&u; p[0] = lo; *************** USE_INLINE double randn (void) *** 552,558 **** * have something to do with this. */ #if defined(ALLBITS) ! # if defined(HAVE_X86) /* 53-bit mantissa, 1-bit sign, x86 32-bit architecture */ double x; int si,idx; --- 552,558 ---- * have something to do with this. */ #if defined(ALLBITS) ! # if HAVE_X86 /* 53-bit mantissa, 1-bit sign, x86 32-bit architecture */ double x; int si,idx; --Apple-Mail-1-551570306-- ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------