octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #54619] randi() is biased


From: Juan Pablo Carbajal
Subject: [Octave-bug-tracker] [bug #54619] randi() is biased
Date: Fri, 7 Sep 2018 21:36:10 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0

Follow-up Comment #13, bug #54619 (project octave):

Thanks for illuminating!

Octave
++
a = randi(6004799503160661,10000,1);
b = a(a>median(a));
c = hist(mod(b,2),[0 1])
c =

   1689   3311
--

Julia seems to get it right
++
using StatsBase
a = rand(1:6004799503160661, Int(1e4));
b = a[a .> median(a)];
h = fit(Histogram, mod.(b,2), nbins=2, closed=:right)

Histogram{Int64,1,Tuple{StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}}}
edges:
  -0.5:0.5:1.0
weights: [2474, 0, 2526]
closed: right
isdensity: false
--
Note: there seems to be abug in fit which fits 3 bins instead of 2

Numpy aslo gets it right
++
import numpy as np
a = np.random.randint(low=1,high=6004799503160661, size=int(1e4))
b = a[a > np.median(a)]
nn, xx = np.histogram(np.mod(b,2), 2)
print(nn, xx)
[2524 2476] [0.  0.5 1. ]
--


>From my view this is now a serious bug, we should fix it asap.


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?54619>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]