numpy sum of squares for matrix

I do have a matrix with observations in rows (measurements at differnt pH) with data points as columns (concentration over time). So one row consists of differnt data points for one pH.

I do want to fit an ODE to the data. So i defined a cost function and would like to calculate the sum of squares for all observatoins. Taking the sum of sqares for this matrix should work like:

res = y - yhat                        # calculate residuals
ssq = np.diag(,res))      # sum over the diagonal

is that correct ?


If you would take the sum of the last array it would be correct. But it's also unnecessarily complex (because the off-diagonal elements are also calculated with Faster is:

ssq = np.sum(res**2)

If you want the ssd for each experiment, you can do:

ssq = np.sum(res**2, axis=1)

Need Your Help

How do I show a marker in Maps launched by geo URI Intent?

android google-maps android-intent android-maps

I have a application where I want to show different locations (one at the time, picked by user input) by launching Google Maps with their specific geo coordinates.

Play alert sound (same as default message ringtone)

iphone audio alert

Is it possible to play some default sounds, such as when an incoming SMS/push is received?