Skip to content

Instantly share code, notes, and snippets.

@gidden
Created January 18, 2016 20:23
Show Gist options
  • Select an option

  • Save gidden/c0c319fa19cc84da1431 to your computer and use it in GitHub Desktop.

Select an option

Save gidden/c0c319fa19cc84da1431 to your computer and use it in GitHub Desktop.
sum of squares
# given an array of data called x:
import numpy as np
sum_of_squares = np.sum(x ** 2)
# if your data is in a list, not a numpy array:
sum_of_squares = np.sum(np.array(x) ** 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment