Wednesday, 22 June, 2005

i found a bug!

crikey... been mulling over some bizarre numbers for weeks... and i think i know why now... hope this de-bugging will clean up the mess... it's all <~isnan>'s fault!

test...

EDU>> t=[1:10 NaN]

t =

1 2 3 4 5 6 7 8 9 10 NaN

EDU>> mean(t(~isnan(t)))

ans =

5.5000

EDU>> mean(t(1:end-1))

ans =

5.5000

EDU>> mean(t(~isnan(t(3:end))))

ans =

4.5000

EDU>> mean(t(3:end-1))

ans =

6.5000

EDU>> (3+4+5+6+7+8+9+10)./8

ans =

6.5000


EDU>> (t(~isnan(t(3:end))))

ans =

1 2 3 4 5 6 7 8

EDU>> (t(~isnan(t)))

ans =

1 2 3 4 5 6 7 8 9 10

EDU>> t(t(~isnan(t)),3:end)
??? Index exceeds matrix dimensions.

EDU>> t(t(~isnan(t)),3:end-1)
??? Index exceeds matrix dimensions.

EDU>> (t(~isnan(t)),3)
??? (t(~isnan(t)),3)
|
Error: ")" expected, "," found.

EDU>> (t(~isnan(t),3:end))
??? Index exceeds matrix dimensions.

EDU>> t(~isnan(t))

ans =

1 2 3 4 5 6 7 8 9 10

EDU>> T=t(~isnan(t))

T =

1 2 3 4 5 6 7 8 9 10

EDU>> T(3:end)

ans =

3 4 5 6 7 8 9 10

EDU>> mean(T(3:end))

ans =

6.5000


baaaah!

posted by ~overacuppa~ on Wednesday, 22 June, 2005 at 13:04 hrs
Comments

oh dear! At least you found and fixed it.

Posted by: monoceros on Thursday, 23 June, 2005 at 15:02 hrs

have found another... it happens a lot when you clean up your scripts... because somethings looks odd and weird and then you try to find the needle in the haysack... the culprit. it's a pain... but we make mistakes and i do that alot in my amaturish programming. =c(

Posted by: overacuppa on Friday, 24 June, 2005 at 10:52 hrs

*Note: in case you were thinking of leaving a comment and the option isn't here anymore... it is because the comment section of each entry is closed after sometime to prevent malicious comments... if you are looking for the actual entry, type in the keyword(s) in the little box on the main page http://overacuppa.com where it says "fossicking pebbles & seashells" and press *search*... thank you for popping by and happy browsing!