From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 8421BBBAF for ; Tue, 30 Sep 2008 15:17:09 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlUDALvD4UjY7zq8emdsb2JhbACTAz4BARQkA6F/bIcgAQI X-IronPort-AV: E=Sophos;i="4.33,338,1220220000"; d="scan'208";a="17505658" Received: from gv-out-0910.google.com ([216.239.58.188]) by mail3-smtp-sop.national.inria.fr with ESMTP; 30 Sep 2008 15:17:09 +0200 Received: by gv-out-0910.google.com with SMTP id o2so2137gve.4 for ; Tue, 30 Sep 2008 06:17:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :content-type:content-transfer-encoding:mime-version:subject:date :x-mailer; bh=JVu7tlGCO3AZu36Jcqker0YMMIBQtbYaPSPgw7WDBCY=; b=kAvJ32aO1pt9ad4RCmWi5KhaNG/Z7xC7QCQUt8ZN75WZrDH2usUSuXuHv9jq2ae+Uf KgW3VBhSS2HmcV/rRAuMspqCmZZdTEedAIUpaQyRMZ1EhuXBlv6iFNwtN0sYpL/8cFG9 N45s33OuvOF2zPvT45TNpSORo8segtfHhdqHM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:content-type:content-transfer-encoding :mime-version:subject:date:x-mailer; b=hyBlaxRrotw92s5kU8ri49NA6vAnUQIkG+VQpImqxdZyTzChPXXaNIkVv6ypddneiq CwO8D4aWLus6xY8SLGV1SL/IZcaRY8TSEyLfWQZTYvPIo0ZDlOOkoGaox8BP674Pbs62 S3Jy5c0NkC6zIaO7/DPHbg6bGa4j3oV8nJFU8= Received: by 10.103.233.12 with SMTP id k12mr4828885mur.54.1222780627398; Tue, 30 Sep 2008 06:17:07 -0700 (PDT) Received: from ?10.4.254.230? (raciborz.rcb.vectranet.pl [88.156.70.2]) by mx.google.com with ESMTPS id e8sm5303759muf.6.2008.09.30.06.17.05 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 30 Sep 2008 06:17:06 -0700 (PDT) Message-Id: From: =?ISO-8859-2?Q?Micha=B3_C?= To: caml-list@yquem.inria.fr Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v929.2) Subject: Random number generator Date: Tue, 30 Sep 2008 15:17:05 +0200 X-Mailer: Apple Mail (2.929.2) X-Spam: no; 0.00; ocaml's:01 integers:01 ruin:98 overflows:01 integer:01 ints:01 int:01 int:01 algorithm:01 algorithm:01 unsigned:02 unsigned:02 module:03 limitations:04 generated:05 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