mathmatical expressions evaluation

beliavsky at aol.com beliavsky at aol.com
Wed Dec 22 16:01:15 EST 2004


Paul McGuire wrote:
>And I wouldn't necessarily agree with beliavsky's assertion that
numarray
>arrays are needed to represent payment dates and amounts, unless you
were
>going to implement a major banking financial system in Python.

Maybe arrays are not "needed", but especially for vectors of floating
point numbers, I prefer to use a Numeric array rather than a list
because

(1) array operations like sum and exp are possible, and I want z = x +
y to perform an element-wise sum rather than a concatenation of lists.
Given arrays containing a set of times, coupon amounts, and interest
rates, the value of a bond could be a calculated with a single
expression, without loops.

(2) A TypeError is raised if I do something illogical like

x = zeros(3,Float)
x[0] = "dog"

(3) Higher-dimensional arrays are better represented with Numeric or
Numarray arrays than with lists.




More information about the Python-list mailing list