[SciPy-User] Order of numpy orperations is not equal to logic (and also octave)?
Sun Oct 31 10:33:11 CDT 2010
On 31/10/2010 08:34, Oz Nahum Tiram wrote:
> Hi Everyone,
> So here is something which I discovered lately and is making me wonder.
> I want to define a scalar which I call Net Absolute Mass Balance Error
> or in short NAMBE. This NAMBE is the absolute difference between a base
> vector and another vector, divided by the base vector and multiplied by
> a hundred, in pseudo-code notation:
> When I do it in python, I decided to break the line into two lines so
> the code is more readable:
> |>>> a=np.array([0.1,0.1,0.1,0.1,0.1])
> array([ 0.2, 0.2, 0.2, 0.2, 0.2])
> array([-0.1, -0.1, -0.1, -0.1, -0.1])
> I thought the numpy does everything element wise so if I do it one line,
> I noticed the the result is different:
> |>>> s=np.sum(abs(a-b)/a)
Math error here: sum((a-b)/a) IS NOT EQUAL TO sum(a-b)/sum(a).
More information about the SciPy-User