search for: marsaglia

Displaying 20 results from an estimated 42 matches for "marsaglia".

2003 May 30
2
Normal deviate generation - Marsaglia's ziggurat method
Hi: I was wondering why Marsaglia's new ziggurat method for generating deviates from the standard normal distribution has not been implemented in the R base package. I know that it is available in SuppDists pacakage of Bob Wheeler, as "rziggurat". According my timing tests, it is about 6 to 7 times faster (on a Pe...
2013 Oct 10
1
Replacing the Random Number Generator in Stand Alone Library
...had a question about the random number generator used in the R StandAlone Math Library. The stand-alone library depends on the unif_rand() function for most simulated values, and this function is provided in the sunif.c file in the relevant directory. At present, this program implements the "Marsaglia-Multicarry" algorithm, which is described throughout the R documentation as: "A multiply-with-carry RNG is used, as recommended by George Marsaglia in his post to the mailing list 'sci.stat.math'. It has a period of more than 2^60 and has passed all tests (according to Marsaglia...
2005 Nov 17
2
R questions
Dear Sir/Madam, I am a beginner in R. Here is my questions. 1. Can you give me one test for randomness (a name and descriptive paragraph is sufficient). 2. I have learned a uniform random number generator [e.g. not the algorithms: i)Wichmann-Hill, ii) Marsaglia-Multicarry, iii) Super-Duper (Marsaglia), iv) Mersenne-Twister, v) TAOCP-1997 (Knuth), or vi) TAOCP-2002 (Knuth)] . Is there any other method besides that? 3. How to generate 100 random standard normal deviates using the Box-Muller method for standard normal random deviates and sort the sequence, s...
2008 Aug 19
1
RNGkind() state (PR#12567)
...it R. > sessionInfo() R version 2.7.1 (2008-06-23) i386--netbsdelf locale: C attached base packages: [1] stats ? ? graphics ?grDevices utils ? ? datasets ?methods ? base > set.seed(1); runif(1)?????????# check the default [1] 0.2655087 > RNGkind("Mar") > RNGkind() [1] "Marsaglia-Multicarry" "Inversion" > set.seed(1); runif(1)?????????# now check again [1] 0.006153224 > set.seed(1)???????????????????# save seed and RNGkind > q("yes") cafe-rozo> ?R R version 2.7.1 (2008-06-23) : etc [Previously saved workspace restored] > runif(1)???...
2008 Aug 17
1
Wichmann-Hill Random Number Generator and the Birthday Problem
...ons. The duplication problem is the interesting birthday problem. If there are M possible numbers, randomly draw N numbers from them, the average number of dupilcations D = N(N-1)/2/M. For Knuth-TAOCP and Knuth-TAOCP-2002, M=2^30, since this modulus is used. D = 46566.12 for N=10M samples. For Marsaglia-Multicarry, Super-Duper and Mersene-Twister, M=2^32. D = 11641.53 for N = 10M samples. My testing results (see below) agree with above analysis. But for Wichmann-Hill, it wasn't. Wichmann-Hill's cycle is 6.9536e12 (refer to RNG help by ?RNG and Whichmann's correction in 1984). Thus...
2003 Jan 09
1
RNG.c: unif_rand, MARSAGLIA_MULTICARRY (PR#2437)
Full_Name: Richard Simard Version: OS: Linux Submission from: (NULL) (132.204.25.139) In the random number generator MARSAGLIA_MULTICARRY, your algorithm is different than the one in the original reference that you give in the R manual: Marsaglia in his post to the mailing list {\it sci.stat.math} on September 29, 1997. The last line in the R program has a ^ while Marsaglia's algorithm has a +. This gives very differen...
1999 Jun 12
0
Random numbers
Hi, I have a few questions about the RNG in R; apologies if these are dumb questions: 1. It is my understanding that, among the three types of random number generators available in R now, the best one is the Marsaglia Multicarry. Is this correct? 2. How does the best RNG in R compare (in terms of quality) to the RNG in SPlus? (based on Marsaglia's Super Duper)? Does the Super-Duper in SPlus pass the MTUPLE test? 3. When running simulations in R, why would I want to use any RNG that is not the Marsaglia-...
2008 Jul 07
0
RNGkind() state
...; to quit R. > sessionInfo() R version 2.7.1 (2008-06-23) i386--netbsdelf locale: C attached base packages: [1] stats graphics grDevices utils datasets methods base > set.seed(1); runif(1) # check the default [1] 0.2655087 > RNGkind("Mar") > RNGkind() [1] "Marsaglia-Multicarry" "Inversion" > set.seed(1); runif(1) # now check again [1] 0.006153224 > set.seed(1) # save seed and RNGkind > q("yes") cafe-rozo> R R version 2.7.1 (2008-06-23) : etc [Previously saved workspace restored] > runif(1) # with a saved seed, Mar...
2003 Oct 16
2
.Random.seed
...following function, a random uniform and the current .Random.seed should be printed: test<-function(runs,seed){ .Random.seed<-seed for (i in 1:runs) { print(i) print(runif(1,0,1)) print(.Random.seed)} return(.Random.seed} Consider the following input/output: >RNGkind(kind="Marsaglia-Multicarry") > set.seed(20391) > seed1<-.Random.seed > seed1 [1] 401 -1607331462 -462081869 > test(2,seed1) [1] 1 [1] 0.4188851 [1] 401 -1607331462 -462081869 [1] 2 [1] 0.7713649 [1] 401 -1607331462 -462081869 [1] 401 -1607331462 -462081869 &g...
2005 Mar 14
2
Bug on MWC1019?
Dear R-developer (Marsaglia??) The following piece of code from package SuppDist , routine "dist.cc" seems to have a bug ULONG MWC1019(void){ ULONG long t; int i = endQ-1; t = 147669672LL*Q[i] + Q[endQ]; Q[endQ] = (t>>32); if(i>0) return(Q[i--] = t); i = endQ-1; return(Q[0] = t); } in fact , b...
1998 Nov 04
1
RNG
On r-help Bill Simpson wrote: >Marsaglia's multiply-with-carry generator is very easy to implement--he >has posted some C code to newsgroups--and seems to test out OK. I wonder >if it would make sense to use one of his generators instead. I would like a system where the random number generator can be specified (perhaps in optio...
2023 Feb 16
0
User-defined RNG with the standalone Rmath library
I have two questions about using a user-defined random number generator (RNG) with the standalone Rmath library. The default RNG with the standalone Rmath library is the Marsaglia-multicarry generator, which has poor properties. The "R Installation and Administration" manual, in the section "The standalone Rmath library", states that: ``` A little care is needed to use the random-number routines. You will need to supply the uniform random number generato...
1999 Apr 28
1
R random number generator
R 0.64 on windows NT 4.0 Sometimes I got an error message by doing this > .Random.seed <- c(1, 1:2) > .Random.seed [1] 1 1 2 > runif(5) Warning: Wrong length .Random.seed; forgot initial RNGkind? set to Wichmann-Hill[1] 0.02253721 0.84832584 ........ Sometimes I do not get error message: > .Random.seed <- c(1, 1:2) > .Random.seed [1] 1 1 2 > runif(1) [1] 0.5641106 >
2002 Aug 12
1
set.seed
...random seed so that I can reproduce a simulation if it's necessary later. Using set.seed, I can certainly get reproducible results, but not the results I get on the first pass. Here's an example: # Generate a random number to initialize > runif(1) [1] 0.965875 > RNGkind() [1] "Marsaglia-Multicarry" "Kinderman-Ramage" > > # Save random seed > temp.seed <- .Random.seed > > # Proceed to generate random uniforms > runif(5) [1] 0.18734034 0.02723140 0.46396251 0.10602243 0.64362777 > > # try to reproduce this sequence > set.seed(temp.seed, &...
2005 Dec 21
2
Random numbers
Hi All. I have R code whose functionality is being replicated within a C+ program. The outputs are to be compared to validate the conversion somewhat - however (as is always the case) I have stuffed my code with random number calls. Random uniform numbers in C+ are being produced using the (Boost) mersenne-twister generators (mt11213b & mt19937) - which is the default type of generator
2003 Mar 28
4
Testing for randomness
Dear all, Is there a test in R for the randomness of a sequence of observations (e.g. to test the random number generator)? Specifically I am looking for autocorrelations which are not necessarily linear in nature, which the acf function does not seem to be flexible enough to detect as it tests for linear autocorrelation. Thanks in advance, Paul.
2002 Jan 27
2
Journal of Statistical Software
...rate section of the journal). Volume 7, 2002, consists so far of the following three issues issue 1: S. Weisberg Dimension reduction regression in R. issue 2: A. Zeileis, F. Leisch, and K. Hornik strucchange: an R package for testing for structural change in linear regression models issue 3: G. Marsaglia and W.W. Tsang Some difficult-to-pass tests of randomness. === Jan de Leeuw; Professor and Chair, UCLA Department of Statistics; US mail: 9432 Boelter Hall, Box 951554, Los Angeles, CA 90095-1554 phone (310)-825-9550; fax (310)-206-5658; email: deleeuw at stat.ucla.edu homepage: http://www.stat....
2002 Jan 27
2
Journal of Statistical Software
...rate section of the journal). Volume 7, 2002, consists so far of the following three issues issue 1: S. Weisberg Dimension reduction regression in R. issue 2: A. Zeileis, F. Leisch, and K. Hornik strucchange: an R package for testing for structural change in linear regression models issue 3: G. Marsaglia and W.W. Tsang Some difficult-to-pass tests of randomness. === Jan de Leeuw; Professor and Chair, UCLA Department of Statistics; US mail: 9432 Boelter Hall, Box 951554, Los Angeles, CA 90095-1554 phone (310)-825-9550; fax (310)-206-5658; email: deleeuw at stat.ucla.edu homepage: http://www.stat....
2012 Jan 27
2
The following code (using rgamma) hangs
...} ################################################ If I add the definitions of `get_seed` and `set_seed` from `src/nmath/standalone/sunif.c` to my code, then the hang disappears. ################################################ #define MATHLIB_STANDALONE #include <Rmath.h> /* A version of Marsaglia-MultiCarry */ static unsigned int I1=1234, I2=5678; void set_seed(unsigned int i1, unsigned int i2) { I1 = i1; I2 = i2; } void get_seed(unsigned int *i1, unsigned int *i2) { *i1 = I1; *i2 = I2; } int main(void) { set_seed(0, 0); rgamma(1, 1); } ##################################...
2008 Aug 14
2
[R] RNG Cycle and Duplication (PR#12540)
...s were: RNGkind(kind=3D"Knuth-TAOCP"); sum(duplicated(runif(1e7))); #return 46552 RNGkind(kind=3D"Knuth-TAOCP-2002"); sum(duplicated(runif(1e7))); #return 46415 #These collision frequency suggested there were 2^30 distinct values by=20 birthday problem. RNGkind(kind=3D"Marsaglia-Multicarry"); sum(duplicated(runif(1e7))); #return 11682 RNGkind(kind=3D"Super-Duper"); sum(duplicated(runif(1e7))); #return 11542 RNGkind(kind=3D"Mersenne-Twister"); sum(duplicated(runif(1e7))); #return 11656 #These indicated there were 2^32 distinct values, which agree...