Skip to main content

All Questions

Tagged with
0 votes
3 answers
108 views

running sum of np.array with widely varying elements

I need to calculate the running sum of np.array. Let's say a is a given np.array of length l and n is an integer step, then I need an array b of length l - n + 1, where b= [a[0]+a[1]+...+a[n-1], a[1]+...
Oleg's user avatar
  • 19
1 vote
1 answer
209 views

Mismatch between Matlab log and Numpy np.log

While rewriting an old Matlab code to NumPy, I noticed differences in logarithmic calculation. In NumPy, I use np.log, Matlab uses log function. b = [1 1 2 3 5 1 1]; p = b ./ sum(b); sprintf('log(%....
Martin Benes's user avatar
1 vote
2 answers
200 views

Handling operations with infinities in python

I have a piece of code that does a simple calculation. import numpy as np #Constants R = 8.314462 T = 298.15 e = -678.692 e_overkbT = e*1000/(R*T) #Independent variable mu = np.linspace(-2000,2000,...
Kyle's user avatar
  • 23
3 votes
2 answers
938 views

arctan2 discrepancy in NumPy

I have come across a puzzling issue when using arctan2 in Numpy. Searching for atan2 errors did not answer the question, but someone might know the reason for this. f = np.arange(0,100) w = 2*np.pi*f/...
vlazzarini's user avatar
3 votes
1 answer
185 views

Tiny numerical difference in sum-of-squares depending on numpy procedure call used

I am writing a function which computes sum of squares of errors. x and y are vectors of the same length; y is observation data, x is data computed by my model. The code is like: >> res = y....
mrad's user avatar
  • 46