From @grubb @ending from redh@t@com  Fri Sep 21 23:33:52 2018
From: @grubb @ending from redh@t@com (Steve Grubb)
Date: Fri, 21 Sep 2018 17:33:52 -0400
Subject: [Rd] Bias in R's random integers?
In-Reply-To: <alpine.DEB.2.21.1809211112290.18675@luke-Latitude-7480>
References: <CAN_1p9wVX=AR8aYtC2LJo0bgN9cRW3XcbYJqnVHdCzA-QA1ceg@mail.gmail.com>
 <5268718.ryNPvsxLyr@x2>
 <alpine.DEB.2.21.1809211112290.18675@luke-Latitude-7480>
Message-ID: <25211226.9na0BstKmx@x2>

On Friday, September 21, 2018 12:38:15 PM EDT Tierney, Luke wrote:
> Not sure what should happen theoretically for the code in vseq.c, but
> I see the same pattern with the R generators I tried (default,
> Super-Duper, and L'Ecuyer) and with with bash $RANDOM using
> 
> N <- 10000
> X1 <- replicate(N, as.integer(system("bash -c 'echo $RANDOM'", intern =
> TRUE))) X2 <- replicate(N, as.integer(system("bash -c 'echo $RANDOM'",
> intern = TRUE))) X <- X1 + 2 ^ 15 * (X2 > 2^14)
> 
> and with numbers from random.org
> 
> library(random)
> X <- randomNumbers(N, 0, 2^16-1, col = 1)
> 
> So I'm not convinced there is an issue.

Indeed. I found the issue: Hex vs Decimal output. If the bash command was
printf "0x%08x\n" $RANDOM, then everything is fine. So, the code in vseq.c 
needs to be  strtoul(buf, NULL, 0);  so that it handles Hex, Decimal, or 
Octal. With this correction to vseq all is fine. No banding in any generated 
image. Corrected program is uploaded.

So, the technique works. When the numbers had a problem, due to a conversion 
error, it showed a distinct pattern. :-)

Best Regards,
-Steve



[Rd] Bias in R's random integers?
Steve Grubb