[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Random number generation quirk
From: |
Jordi Gutiérrez Hermoso |
Subject: |
Re: Random number generation quirk |
Date: |
Fri, 28 Feb 2014 08:20:03 -0500 |
On Thu, 2014-02-27 at 18:56 -0800, mpender wrote:
> This normally returns a number between 1 and 10. But sometimes I get
> some difficult to trace array index out of bound errors when I use
> the computed value as an array index. I suspect that sometimes the
> rand function returns exactly 1.0 and then round (1.0 * 10 + 0.5) =
> 11 , which results in my index out of bounds condition.
I'm unable to reproduce this after getting a few billion random
numbers out of rand. If rand is actually ever giving you exactly 1,
this is a bug. Are you able to see a bug?
http://hg.savannah.gnu.org/hgweb/octave/file/c579bd4e12c9/liboctave/numeric/randmtzig.c#l400
- Jordi G. H.