Re: random numbers in fortran




"Herman D. Knoble" <SkipKnobleLESS@xxxxxxxxxxxxxxx> wrote in message
news:s8rtm290h0lbp0rh87hj30r0rfv0d6ok29@xxxxxxxxxx

I'd suggest to the original posters that they do BOTH/AND:
Both seek expert statistician's/mathematician's advice, and
seek comp.lang.fortran advice.

Yes, I agree. Nevertheless, for fun, here's a program that should print the
values

10000 10000 1.0000000 1.0000000

but the RNG has been doctored to ensure that the second card dealt has the
same suit as the first. The bias is easily detected.

Regards,

Mike Metcalf

implicit none
integer :: hit(52, 52) = 0, numbers(52), lots = 10000, i, j
real(kind=kind(0d0)) :: bias(52, 52)

do i = 1, lots*52
numbers = scatter(52)
do j = 1, 52
hit(j, numbers(j)) = hit(j, numbers(j)) + 1
end do
end do

bias = real(hit)/lots

print *, minval(hit), maxval(hit), sum(bias)/52**2, &
sqrt(sum(((bias - 1.0d0)**2)/52**2)*lots)

contains

function scatter(nn)
integer :: nn, scatter(nn), ii, index
real :: numbers(nn)

1 call random_number(numbers)
do ii = 1, nn
index = minloc(numbers, dim=1)
scatter(ii) = index
numbers(index) = 2.0
end do

if(scatter(1) <= 13 .and. scatter(2) > 13) go to 1 ! <----- bias added
here

end function scatter

end





.



Relevant Pages

  • [40k] Age of Strife Warhammer World weekend
    ... but I will post up a group shot photo with name guide later. ... a game of fun for the players involved, and his advice to those who need an ... argue over the rules then why bother playing, as instead of being fun it ... this advice while playing, and had a lot more fun for doing so. ...
    (rec.games.miniatures.warhammer)
  • Re: DEep breaths. ITS ONLY A NG...BEWARE REALLY BAD WORDS
    ... >> Those words were posted to me years ago by you, along with the advice ... You can deny your responsibility ... Telling people how to fix their ... >> fun as tormenting people like Lori. ...
    (alt.med.fibromyalgia)
  • Re: 4th Edition Missed an Oppurtunity?
    ... David Lamb wrote in ... gaming style that's as much improvisational acting as gaming, ... of the XDM oath about making certain everyone has fun. ... Mind you, as general advice, it's good. ...
    (rec.games.frp.dnd)
  • Re: New primary key field
    ... This is the most fun I have in a usual weeks. ... responses have been made while attending vendor meetings. ... "I didn't need any advice" should be changed to "I didn't want ... and it's the first time I've seen folks in attack mode, Zach. ...
    (microsoft.public.sqlserver.programming)
  • Re: CLOSED Re: Obtaining complete Unix command line that evoked script as string
    ... Important point is that I'm not not taking your advice because I've got an attitude or I think your "wrong", I'm not taking it because it doesn't fit my particular purpose. ... To repeat from my earlier post: I don't have a choice about using a mixture of shell and perl, its not something I can choose, even if I wanted to. ... But just for fun, by analogy, your quote makes an assumption; it assumes the water isn't filthy, polluted and off-putting to the horse in which case you probably couldn't even lead a *sensible* horse to it :-) A smart horse might choose to be stubborn because it can see it doesn't make sense.. ... In other words a rube goldberg machine will work, and it can be fun to fiddle with, but there are more practical ways to do it in general, but still a rube goldberg isn't bad mind you just not as efficient or easy to take around with you. ...
    (perl.beginners)