From bug-request at octave dot org Wed May 18 08:08:21 2005 Subject: version 2.1.69 under mac OS X: randn does not work properly From: "John W. Eaton" To: =?ISO-8859-1?Q?Sa=EFd?= Cc: bug at octave dot org Date: Wed, 18 May 2005 09:04:43 -0400 On 18-May-2005, Sa=EFd wrote: | Hi, |=20 | I am using the version 2.1.69 of octave under mac OS X 10.3.9,=20 | (hardware: iBook G4). I downloaded the binary version from: |=20 | http://hpc.sourceforge.net/ |=20 | It seems to have a very serious bug affecting the gaussian random=20 | generator: |=20 | Here is an example | ---------------------------- | dhcp132-235-~ $ octave | GNU Octave, version 2.1.69 (powerpc-apple-darwin7.8.0). | Copyright (C) 2005 John W. Eaton. | This is free software; see the source code for copying conditions. | There is ABSOLUTELY NO WARRANTY; not even for MERCHANTIBILITY or | FITNESS FOR A PARTICULAR PURPOSE. For details, type `warranty'. |=20 | Additional information about Octave is available at=20 | http://www.octave.org. |=20 | Please contribute if you find this software useful. | For more information, visit http://www.octave.org/help-wanted.html |=20 | Report bugs to (but first, please read | http://www.octave.org/bugs.html to learn how to write a helpful repor= t). |=20 | octave:1> x=3Drandn(1,10000); | octave:2> sum(x>3) | ans =3D 4001 | ------------------ |=20 | Using a proper random generator, the last answer would have been more= =20 | like 10. |=20 | I also use the version 2.1.53 (from the Fink project) which does no= t=20 | have this problem. |=20 | Workaround: | You can replace: |=20 | x=3Drandn(1,N); |=20 | by |=20 | x=3Dsum(rand(12,N)-0.5); |=20 | to get a nearly-gaussian distribution. There are unfortunately different versions of rand for Octave. If you have installed octave-forge, then you are getting the alternate version, which appears to have the bug (may already be fixed in the CVS sources, I don't know). But the version that is distributed as a part of Octave does not appear to have the problem. jwe ------------------------------------------------------------- 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 -------------------------------------------------------------