Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Till Varoquaux" <till.varoquaux@gmail.com>
To: "Michał C" <ciebiada@gmail.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Random number generator
Date: Tue, 30 Sep 2008 14:36:56 +0100	[thread overview]
Message-ID: <9d3ec8300809300636w4223f480uf7c7008e08354054@mail.gmail.com> (raw)
In-Reply-To: <E1377AE6-AA53-434D-B293-CDF4529651C2@gmail.com>

It apparently [1] passed the die hard test so it should be pretty
solid. Now here comes the warning: one can only prove that PRNG are
bad, withstanding the test of time is the best hint fir quality.
Random numbers are a tricky subject; if you are using them for your
ray tracer a low-discrepancy sequence[2] might prove a better match.

Till
[1]http://groups.google.com/group/fa.caml/browse_thread/thread/eb5ba7eef6e43066
[2]http://en.wikipedia.org/wiki/Low-discrepancy_sequence

On Tue, Sep 30, 2008 at 2:17 PM, Michał C <ciebiada@gmail.com> wrote:
> Hello!
>
> Do You maybe have any idea how good is the standard RNG from random.ml
> module? I know that it's quite fast but what about the quality of generated
> numbers?
>
> I've tried implementing various random number generators for the whole
> yesterday but I couldn't bypass ocaml's int limitations. Almost everything
> bases on unsigned integers (0..2^32-1) so despiting the fact my range is
> half of that (using Int32) I'm having troubles when integer overflows...
>
> I would like to implement combined MWC (multiple with carry) algorithm based
> on 2 x 16bit mwc's. I'ts very easy (at last in c/c++ where i can use
> unsigned ints), fast and according to what I've read it's generating very
> nice random numbers.
>
> It goes like this:
>
> z = w= some seeds (big numbers)
>
> z  = 36969 * (z & 65535) + (z >> 16)
> w = 18000 * (w & 65535) + (w >> 16)
> return ( (z << 16) + (w & 65535) )              // combining two 16 bit
> numbers to one 32 bit
>
>
> but i cant think of anything by myself, i mean i could use some "abs" or
> something but i doubt it wouldn't ruin the whole algorithm.
>
> P.S.
> some time ago I promised that I will keep you informed how my ray-tracer
> will do, here it is:
> http://neos1.blogspot.com
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>



-- 
http://till-varoquaux.blogspot.com/

      reply	other threads:[~2008-09-30 13:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-30 13:17 Michał C
2008-09-30 13:36 ` Till Varoquaux [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9d3ec8300809300636w4223f480uf7c7008e08354054@mail.gmail.com \
    --to=till.varoquaux@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=ciebiada@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox