• Home
  • Search Tags
  • About

numpy

Topics related to numpy:

Getting started with numpy

NumPy (pronounced “numb pie” or sometimes “numb pea”) is an extension to the Python programming language that adds support for large, multi-dimensional arrays, along with an extensive library of high-level mathematical functions to operate on these arrays.

Arrays

Whenever possible express operations on data in terms of arrays and vector operations. Vector operations execute much faster than equivalent for loops

Generating random data

numpy.dot

numpy.dot

Returns the dot product of a and b. If a and b are both scalars or both 1-D arrays then a scalar is returned; otherwise an array is returned. If out is given, then it is returned.

Linear algebra with np.linalg

As of version 1.8, several of the routines in np.linalg can operate on a 'stack' of matrices. That is, the routine can calculate results for multiple matrices if they're stacked together. For example, A here is interpreted as two stacked 3-by-3 matrices:

np.random.seed(123)
A = np.random.rand(2,3,3)
b = np.random.rand(2,3)
x = np.linalg.solve(A, b)

print np.dot(A[0,:,:], x[0,:])
# array([ 0.53155137,  0.53182759,  0.63440096])

print b[0,:]
# array([ 0.53155137,  0.53182759,  0.63440096])

The official np docs specify this via parameter specifications like a : (..., M, M) array_like.

File IO with numpy

Boolean Indexing

numpy.cross

Filtering data

subclassing ndarray

Simple Linear Regression

Saving and loading of Arrays

Content on the page is taken from Stack Overflow Documentation

This site is NOT affiliated with Stack Overflow or any of the contributors. | Privacy Policy | Terms of Service