>> norm = 1 / (scale * sqrt(2 * pi))
>> y = norm * exp(-power((x - loc), 2) / (2 * scale**2))
>
>   Hmm-m-m. I don't understand the source of the error:
>
>   y = norm * exp(-pow((x - loc), 2) / (2 * scale**2))
> TypeError: only length-1 arrays can be converted to Python scalars

Python's built in pow() and exp() functions can't handle numpy arrays,  
and thus try (and fail) to convert arrays to scalar values. You want  
to use numpy.exp and numpy.power (or just the ** operator), to do  
these operations to numpy arrays elementwise.
_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to