lua-users home
lua-l archive

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


On Tue, 8 May 2018, Rodrigo Azevedo wrote:

> Just an update of a real-world application. I'm working on a
> scientific stochastic code that "can" use the default PRNG of luajit
> and lua-5.4.0-work1 (don't worry!). Compared to luajit,
> lua-5.4.0-work1 exhibits a higher convergence rate, which is a symptom
> of a (maybe) better PRNG. Moreover,  luajit is "only" 60% faster (no
> I/O bound) than lua-5.4.0-work1, which makes me think about forgetting
> luajit forever.

Just a remark, if good convergence rate is needed, e. g. for Monte Carlo
simulation or integration, Halton or Sobol "low-discrepancy" sequences
may perform better than PRNG and can be used as drop-in replacements. E.
g.,

local halton = function (index, base)
-- from en.wikipedia.org/wiki/Halton_sequence
  local result = 0
  local f = 1
  local i = index
  while i > 0 do
    f = f / base
    result = result + f * (i % base)
    i = math.floor(i / base)
  end
  return result
end

Regards, Hartmut