You are on page 1of 2

Some Important Functions of Numpy (A guide

for Videos 2.2- NumPy Intro Part-2)

• Linalg.solve Function- This function is used to solve linear scalar equations. Eg. If we have
three equations and three unknowns, this function is used to find the value of the unknowns.

Please refer to the link for more


details- https://numpy.org/doc/stable/reference/generated/numpy.linalg.solve.html (Links to an
external site.)Links to an external site.

Syntax :np.linalg.solve(a, b)
Parameters :

a-Coefficient Matrix
b-Dependent Variables

• Unique Function: This function will give you all the unique elements in any order.

Syntax: np.unique(array)

• Random.rand Function- This function creates an array of the given shape and populate it
with random samples from a uniform distribution over [0, 1).

Syntax: np.random.rand(d0,d1,……, dn)


Parameters :
d0, d1, …, dn : The dimensions of the returned array, should all be positive. If no argument is
given a single Python float is returned.

• Random.randn Function- Return a sample (or samples) from the “standard normal”
distribution. Standard Normal Distribution has a mean of 0 and a Standard Deviation of 1.

Syntax: np.random.randn(d0,d1,……, dn)

Parameters :
d0, d1, …, dn : The dimensions of the returned array, should all be positive. If no argument is
given a single Python float is returned.

• Mean function- This function is used to compute the arithmetic mean of the given array
along a specific axis.

Syntax: np.mean(arr, axis = None)

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Parameters :
arr : input array.
axis : axis = 0 means mean to be calculated along the column and axis = 1 means mean to be
calculated along the row. If you will not specify any axis, this function will calculate the mean for
all elements.

• Std function- This function is used to calculate the standard deviation of an array along the
given axis.

Syntax: np.std(arr, axis = None)


Parameters :
arr : input array.
axis : axis = 0 means std to be calculated along the column and axis = 1 means std to be
calculated along the row. If you will not specify any axis, this function will calculate the Standard
Deviation considering all the elements.

• Min function- This function will display the minimum value in the array or minimum value in
the specified axis.

Syntax: np.min(arr, axis = None)

Parameters :
arr : input array.
axis : axis = 0 means minimum to be displayed along the column and axis = 1 means minimum
to be displayed along the row. If you will not specify any axis, this function will display the
minimum considering all the elements.

• Max function- This function will display the maximum value in the array or maximum value
in the specified axis.

Syntax: np.max(arr, axis = None)


Parameters :
arr : input array.
axis : axis = 0 means maximum to be displayed along the column and axis = 1 means maximum
to be displayed along the row. If you will not specify any axis, this function will display the
minimum considering all the elements.

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.

You might also like