Prev: pointer and allocatable arrays
Next: f95 to windows dll
From: robin on 21 Nov 2009 17:24 <nmm1(a)cam.ac.uk> wrote in message news:he4ac9$q2m$1(a)smaug.linux.pwf.cam.ac.uk... | In article <%ShNm.55991$ze1.49888(a)news-server.bigpond.net.au>, | robin <robin_v(a)bigpond.com> wrote: | >"David Flower" <DavJFlower(a)AOL.COM> wrote in message | >news:8b69b09f-fd08-44a2-a48b-03afab751b88(a)z41g2000yqz.googlegroups.com... | > | >>Posters may be interested in the following reference: | > | >>A.C.M. Trans. Math, Software, 5, #2, 132 (1979) by Linus Schrage | > | >It's a bit ancient. | >Those by George Marsaglia are not only portable, | >they also have extremely long periods. | > | >His RNGs include 32-bit generators and 64-bit generators. | | 32-bit generators should never be used in any simulation which | uses more than a million numbers in total. George's 32-bit RNG KISS has a period > 10**35 numbers. He has put his RNGs through exhaustive tests. | To a first approximation, | ALWAYS use 64-bit ones. | | Not all of Marsaglia's generators are free from 32-bit defects, even | when they are used in 64-bit forms, though most of them are good or | very good. Their actual code isn't always very portable, but that's | easy to clean up. Don't know about his early ones, but those of the past decade or so have been rigorously tested and have extremely long runs. The 64-bit RNG KISS has a period greater than 10**75. Their performances are pretty impressive.
From: robin on 21 Nov 2009 17:24 <nmm1(a)cam.ac.uk> wrote in message news:he4ac9$q2m$1(a)smaug.linux.pwf.cam.ac.uk... | Not all of Marsaglia's generators are free from 32-bit defects, even | when they are used in 64-bit forms, though most of them are good or | very good. Their actual code isn't always very portable, but that's | easy to clean up. His RNGs are portable to other languages. He published them in C and Fortran, and I ported some to PL/I. They produce the same results regardless of language. As cross-platform RNGs, they produce the same RNs. That's about as portable as you can get. I agree that some of the Fortran versions need tidying up for portability across Fortran compilers.
From: nmm1 on 21 Nov 2009 17:39 In article <AMZNm.56548$ze1.49885(a)news-server.bigpond.net.au>, robin <robin_v(a)bigpond.com> wrote: > >| 32-bit generators should never be used in any simulation which >| uses more than a million numbers in total. To a first approximation, >| ALWAYS use 64-bit ones. > >32-bit generators have been used since time immemorial, >and most were OK for pretty well all kinds of work. Don't bet on it. I have seen a lot of people get wrong answers by using them, cured by moving to 64-bit ones. >George Marsaglia's KISS RNG has a period greater than >10**35, which is far far far greater than the 10**6 figure >that you suggest. Sigh. I am not talking about the period, but the precision, and the discreteness starts to become a serious problem if any one simulation uses more than about a million numbers. Regards, Nick Maclaren.
From: frank on 22 Nov 2009 01:54 On Wed, 18 Nov 2009 14:10:26 -0600, Ron Shepard wrote: > In article <7meelsF3g7qejU1(a)mid.individual.net>, > frank <frank(a)example.invalid> wrote: > >> Isn't there an asymmetry in the unit interval though as to which >> endpoint is included? So if there's N outcomes on one side of .5 there >> would be N +-1 on the other. > > There are more floating point values between 0 and .5 than there are > between .5 and 1. It is not just a difference of +-1 value. Should all > such values occur in the pseudorandom sequence, or only a subset of such > values? > > $.02 -Ron Shepard I thought I'd try to enumerate the reals in my implementation in the neighborhood of .5 . I was expecting that many representations would correspond to a single decimal one, but not so if this achieves its goal: dan(a)dan-desktop:~/source$ gfortran real1.f90 -Wall -o out dan(a)dan-desktop:~/source$ ./out mult was 151 mult was 151 mult was 151 mult was 300 mult was 300 mult was 300 mult was 300 mult was 300 mult was 300 mult was 300 mult was 300 mult was 300 mult was 300 mult was 300 myarray is 0.49999991 0.49999994 0.49999997 0.50000000 0.50000006 0.50000012 0.50000018 0.50000024 0.50000030 0.50000036 0.50000042 0.50000048 0.50000054 0.50000060 0.50000066 epsilon is 3.00000000000000039E-008 number of reals in unit interval sp gfortran on ubuntu: 33333333.333333328 dan(a)dan-desktop:~/source$ cat real1.f90 implicit none INTEGER, PARAMETER :: SP=SELECTED_REAL_KIND(6,37) INTEGER, PARAMETER :: DP=SELECTED_REAL_KIND(15,307) REAL(KIND=SP) :: begin, B, C REAL(KIND=DP) :: V, accum, summa, epsilon integer, parameter :: r = 15 real(KIND=SP), dimension(1:r) :: myarray integer i, mult v = .0000000001_dp begin = .4999999_sp myarray(1) = begin do i =2,r ! inner control mult = 0 accum = 0.0_dp b = myarray ( i - 1) c = myarray ( i - 1) summa =0.0_dp do while ( b == c ) accum = mult * v !print *, "accum is ", accum summa = accum + real(b, kind=dp) c = real(summa, kind=sp) mult = mult + 1 !print * , mult end do print * ,"mult was", mult myarray(i) = c end do print *, "myarray is ", myarray epsilon = mult * v print *, "epsilon is ", epsilon print *, "number of reals in unit interval sp gfortran on ubuntu: ", 1.0/ epsilon end program ! gfortran real1.f90 -Wall -o out dan(a)dan-desktop:~/source$ I'd be very surprised if this were methodologically sound, but it was fun to make the try after months of not having touched a fortran compiler. Cheers, -- frank "Guns: yes, they are harmful."
From: robin on 23 Nov 2009 07:01
<nmm1(a)cam.ac.uk> wrote in message news:he9q7p$7ki$1(a)smaug.linux.pwf.cam.ac.uk... | In article <AMZNm.56548$ze1.49885(a)news-server.bigpond.net.au>, | robin <robin_v(a)bigpond.com> wrote: | > | >| 32-bit generators should never be used in any simulation which | >| uses more than a million numbers in total. To a first approximation, | >| ALWAYS use 64-bit ones. | > | >32-bit generators have been used since time immemorial, | >and most were OK for pretty well all kinds of work. | | Don't bet on it. I have seen a lot of people get wrong answers | by using them, cured by moving to 64-bit ones. | | >George Marsaglia's KISS RNG has a period greater than | >10**35, which is far far far greater than the 10**6 figure | >that you suggest. | | Sigh. I am not talking about the period, but the precision, and | the discreteness starts to become a serious problem if any one | simulation uses more than about a million numbers. Your claims are vague and are unsubstantiated. You have not said anything about about Marsaglia's specific 32-bit and 64-bit generators. Nor have you suppled any information about the 32-bit generators that you claim to have noticed. |