[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #54619] randi() is biased
From: |
anonymous |
Subject: |
[Octave-bug-tracker] [bug #54619] randi() is biased |
Date: |
Tue, 4 Sep 2018 12:41:00 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0 |
URL:
<http://savannah.gnu.org/bugs/?54619>
Summary: randi() is biased
Project: GNU Octave
Submitted by: None
Submitted on: Tue 04 Sep 2018 04:40:58 PM UTC
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Inaccurate Result
Status: None
Assigned to: None
Originator Name: Cris Luengo
Originator Email: address@hidden
Open/Closed: Open
Discussion Lock: Any
Release: 4.0.0
Operating System: Any
_______________________________________________________
Details:
The randi function uses an incorrect algorithm that leads to biased results.
It is implemented in terms of `rand`. But `rand` is created by dividing the
output of a 64-bit random number generator by 2^64-1, scaling this value up
and rounding down doesn't lead to a uniform distribution, as the original
integer intervals are most likely not evenly divisible into the output
interval, and thus some output values are slightly more likely than other
output values.
This is maybe only a small bias, but it is there.
See here for a correct algorithm:
https://stackoverflow.com/questions/2509679/how-to-generate-a-random-integer-number-from-within-a-range/6852396#6852396
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?54619>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #54619] randi() is biased,
anonymous <=
- [Octave-bug-tracker] [bug #54619] randi() is biased, Rik, 2018/09/05
- [Octave-bug-tracker] [bug #54619] randi() is biased, anonymous, 2018/09/06
- [Octave-bug-tracker] [bug #54619] randi() is biased, Rik, 2018/09/06
- [Octave-bug-tracker] [bug #54619] randi() is biased, anonymous, 2018/09/06
- [Octave-bug-tracker] [bug #54619] randi() is biased, Rik, 2018/09/06
- [Octave-bug-tracker] [bug #54619] randi() is biased, Juan Pablo Carbajal, 2018/09/06
- [Octave-bug-tracker] [bug #54619] randi() is biased, Michael Godfrey, 2018/09/06
- [Octave-bug-tracker] [bug #54619] randi() is biased, Michael Godfrey, 2018/09/07
- [Octave-bug-tracker] [bug #54619] randi() is biased, Rik, 2018/09/07
- [Octave-bug-tracker] [bug #54619] randi() is biased, Michael Godfrey, 2018/09/07