Search⌘ K
AI Features

Solution Review: Using Numpy and Scipy

Explore how to use NumPy and SciPy libraries to perform essential statistical calculations such as maximum value, standard deviation, sum, dot product, correlation, and p-value. This lesson helps you understand applying these functions to arrays for data analysis tasks using Python basics, preparing you for more advanced data handling.

We'll cover the following...

Numpy

Python 3.5
import numpy as np # importing numpy module
def perform_calculations(array):
# returning max, std, sum, and dot product
return np.max(array), np.std(array), np.sum(array), np.dot(array, array)
# calling the function and printing result
print(perform_calculations(np.random.rand(5)))

According to the problem statement, we needed these four values using one numpy 1-D array as an output: max, std, sum, and dot product. In the code above, at line 1 we imported the numpy module for this purpose. Next, we ...