From Andre@G||||bert @end|ng |rom chu-rouen@|r  Thu Aug 12 12:26:44 2021
From: Andre@G||||bert @end|ng |rom chu-rouen@|r (GILLIBERT, Andre)
Date: Thu, 12 Aug 2021 10:26:44 +0000
Subject: [Rd] Problem in random number generation for Marsaglia-Multicarry +
 Ahrens-Dieter
Message-ID: <edcc1ed20f6a464ca0f49f77e5b8c225@chu-rouen.fr>

Dear R developers,

At the same time I discovered a flaw in Marsaglia-Multicarry + Kinderman-Ramage, I found another in Marsaglia-Multicarry + Ahrens-Dieter.
It is less obvious than for Kinderman-Ramage; so I created a new thread for this bug.

The following code shows the problem (tested on R 4.1.1 x86_64 for Windows 10):

== start of code sample ==
set.seed(1, "Marsaglia-Multicarry", normal.kind="Ahrens-Dieter")
v=rnorm(1e8)

q=qnorm(seq(0.01, 0.99, 0.01))
cv=cut(v, breaks=c(-Inf, q, +Inf))
observed=table(cv)
chisq.test(observed) # p < 2.2e-16
== end of code sample ==

The chisq.test returns a P-value < 2.2e-16 while it was expected to return a non-significant P-value.
The additionnal code below, shows severe irregularities in the distribution of quantiles:

== continuation of code sample ==
expected = chisq.test(observed)$expected
z = (observed - expected)/sqrt(expected)
mean (abs(z) > 6) # 58% of z-scores are greater than 6 while none should be
== end of code sample ==

The bug is specific to the combination Marsaglia-Multicarry + Ahrens-Dieter.
There is no problem with Marsaglia-Multicarry + Inversion or Mersenne-Twister + Ahrens-Dieter

I would expect at least a warning (or an error) from R for such a buggy combination.

--
Sincerely
Andr? GILLIBERT


	[[alternative HTML version deleted]]



[Rd] Problem in random number generation for Marsaglia-Multicarry + Ahrens-Dieter
GILLIBERT, Andre