[Numpy-discussion] Different results from repeated calculation

Keith Goodman kwgoodman at gmail.com
Sat Jan 27 14:25:18 CST 2007


I get slightly different results when I repeat a calculation. In a
long simulation the differences snowball and swamp the effects I am
trying to measure.

In the attach script there are three tests.

In test1, I construct matrices x and y and then repeatedly calculate z
= calc(x,y). The result z is the same every time. So this test passes.

In test2, I construct matrices x and y each time before calculating z
= calc(x,y). Sometimes z is slightly different---of the order of 1e-21
to 1e-18. But the x's test to be equal and so do the y's. This test
fails. (It doesn't fail on my friend's windows box; I'm running
linux.)

test3 is the same as test2 but I calculate z like this: z = calc(100*x
,y) / (100 * 100). This test passes.

What is going on?

Here is some sample output:

>> import repeat
>> repeat.all()
4 z different 8.47032947254e-22
5 z different 8.47032947254e-22
7 z different 8.47032947254e-22
9 z different 8.47032947254e-22
10 z different 8.47032947254e-22
16 z different 8.47032947254e-22
24 z different 8.47032947254e-22
25 z different 8.47032947254e-22
26 z different 8.47032947254e-22
27 z different 8.47032947254e-22
30 z different 8.47032947254e-22
32 z different 8.47032947254e-22
34 z different 8.47032947254e-22
35 z different 8.47032947254e-22
36 z different 8.47032947254e-22
39 z different 8.47032947254e-22
40 z different 8.47032947254e-22
41 z different 8.47032947254e-22
45 z different 8.47032947254e-22
46 z different 8.47032947254e-22
50 z different 8.47032947254e-22
52 z different 8.47032947254e-22
53 z different 8.47032947254e-22
55 z different 8.47032947254e-22
56 z different 8.47032947254e-22
58 z different 8.47032947254e-22
66 z different 8.47032947254e-22
67 z different 8.47032947254e-22
71 z different 8.47032947254e-22
73 z different 8.47032947254e-22
74 z different 8.47032947254e-22
83 z different 8.47032947254e-22
86 z different 8.47032947254e-22
87 z different 8.47032947254e-22
88 z different 8.47032947254e-22
89 z different 8.47032947254e-22
90 z different 8.47032947254e-22
92 z different 8.47032947254e-22

test1:  0  differences
test2:  38  differences
test3:  0  differences

Repeated runs tend to give me the same number of differences in test2
for several runs. Then I get a new number of differences which last
for severals runs...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: repeat.py
Type: text/x-python
Size: 2030 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070127/52b3a51c/attachment.py 


More information about the Numpy-discussion mailing list