| Re: random ints on symmetric interval |
|
 |
|
 |
|
 |
|
 |
Group: comp.lang.fortran · Group Profile
Author: Ron FordRon Ford Date: Sep 16, 2008 23:52
On Tue, 16 Sep 2008 20:45:39 -0700 (PDT), e p chandler posted:
> No. It looks like you have an off by one bug. Consider this test
> program:
I think I have it, as shown by adding up the outcomes:
summa = sum (k)
print *, "sum =", summa
n= 1
clock= 311964079
seed= 311964079
1 0.809851
2 0.268532
3 0.787813
4 0.293169
C =
F =
k is 0 324 387
338 366
373 398 393
376 409
374 346 345
368 372
352 379 386
369 354
364 407 374
379 371
341 387
sum = 9632.00
system clock was 0.00000
cpu time was 0
Press RETURN to close window . . .
I seemed to be missing 370, which is the ev of an outcome.
With:
F(i) = C(i) - i_max - 1
, I get all the outcomes.
2 questions here.
1) Why do I believe that
b = min(max(1,ceiling(harvest*sides)),sides)
is better than
b = -i_max + int( harvest * i_tot )
?
2) How did I not write out of bounds on an array with affairs being off by
one ??
--
Most people are unable to write because they are unable to think, and they
are unable to think because they congenitally lack the equipment to do so,
just as they congenitally lack the equipment to fly over the moon.
H. L. Mencken
|