print numpy.arange(5)

print numpy.linspace(0, 5, 10, endpoint=False)

print numpy.zeros(5)

print numpy.ones(5)

print numpy.ones((5,2))

print scipy.randn(5) # random Gaussian, zero-mean unit-variance

print scipy.randn(5,2)

"""
Explanation: &larr; Back to Index
NumPy and SciPy
The quartet of NumPy, SciPy, Matplotlib, and IPython is a popular combination in the Python world. We will use each of these libraries in this workshop.
Tutorial
NumPy is one of the most popular libraries for numerical computing in the world. It is used in several disciplines including image processing, finance, bioinformatics, and more.  This entire workshop is based upon NumPy and its derivatives.
If you are new to NumPy, follow this NumPy Tutorial.
SciPy is a Python library for scientific computing which builds on top of NumPy. If NumPy is like the Matlab core, then SciPy is like the Matlab toolboxes. It includes support for linear algebra, sparse matrices, spatial data structions, statistics, and more.
While there is a SciPy Tutorial, it isn't critical that you follow it for this workshop.
Special Arrays
End of explanation
"""


x = numpy.arange(10)
print x[2:4]

print x[-1]

"""
Explanation: Slicing Arrays
End of explanation
"""


print x[0:8:2]

print x[4:2:-1]

"""
Explanation: The optional third parameter indicates the increment value:
End of explanation
"""


print x[:4]

print x[:999]

print x[::-1]

"""
Explanation: If you omit the start index, the slice implicitly starts from zero:
End of explanation
"""


x = numpy.arange(5)
y = numpy.ones(5)
print x+2*y

"""
Explanation: Array Arithmetic
End of explanation
"""


x = scipy.randn(5)
y = numpy.ones(5)
print numpy.dot(x, y)

x = scipy.randn(5,3)
y = numpy.ones((3,2))
print numpy.dot(x, y)

"""
Explanation: dot computes the dot product, or inner product, between arrays or matrices.
End of explanation
"""


x = numpy.arange(10)
print x < 5

y = numpy.ones(10)
print x < y

"""
Explanation: Boolean Operations
End of explanation
"""


from scipy.spatial import distance
print distance.euclidean([0, 0], [3, 4])
print distance.sqeuclidean([0, 0], [3, 4])
print distance.cityblock([0, 0], [3, 4])
print distance.chebyshev([0, 0], [3, 4])

"""
Explanation: Distance Metrics
End of explanation
"""


print distance.cosine([67, 0], [89, 0])
print distance.cosine([67, 0], [0, 89])

"""
Explanation: The cosine distance measures the angle between two vectors:
End of explanation
"""


x = scipy.randn(5)
print x
x.sort()
print x

"""
Explanation: Sorting
NumPy arrays have a method, sort, which sorts the array in-place.
End of explanation
"""


x = scipy.randn(5)
print x
ind = numpy.argsort(x)
print ind
print x[ind]

"""
Explanation: numpy.argsort returns an array of indices, ind, such that x[ind] is a sorted version of x.
End of explanation
"""


