You are on page 1of 4

Numpy

| Mathematical Function
NumPy contains a large number of various
mathematical operations. NumPy provides
standard trigonometric functions, functions
for arithmetic operations, handling complex
numbers, etc.

Trigonometric Functions – NumPy has standard trigonometric


functions which return trigonometric ratios for a given angle in
radians

numpy.cos(x[, out]) = ufunc ‘cos’) : This mathematical function helps


user to calculate trignmetric cosine for all x(being the array elements).
numpy.ptp() function
The name of the function numpy.ptp() is derived from the name peak-to-
peak. It is used to return the range of values along an axis. Consider the
following example.

1. import numpy as np
output
2.
3. a = np.array([[2,10,20],[80,43,31],[22,43,10]])
Original array:
4.
[[ 2 10 20]
5. print("Original array:\n",a)
[80 43 31]
6.
[22 43 10]]
7. print("\nptp value along axis 1:",np.ptp(a,1))
ptp value along axis 1: [18 49 33]
8.
ptp value along axis 0: [78 33 21]
9. print("ptp value along axis 0:",np.ptp(a,0))
numpy.percentile() function
The syntax to use the function is given below.
1. numpy.percentile(input, q, axis

It accepts the following parameters.)

1. input: It is the input array.


2. q: It is the percentile (1-100) which is calculated of the
array element.
3. axis: It is the axis along which the percentile is to be
calculated.

You might also like