Found 1204 Articles for Numpy

Return the natural logarithm of one plus the input array element-wise in Numpy

AmitDiwan
Updated on 08-Feb-2022 10:06:14

130 Views

To return the natural logarithm of one plus the input array, element-wise., use the numpy.log1p() method in Python Numpy. It calculates log(1 + x).For complex-valued input, log1p is a complex analytical function that has a branch cut [-inf, -1] and is continuous from above on it. log1p handles the floating-point negative zero as an infinitesimal negative number, conforming to the C99 standard.StepsAt first, import the required library −import numpy as npCreate an array using the array() method −arr = np.array([1e-15, 10000, 1e-99]) Display the array −print("Array...", arr)Get the type of the array −print("Our Array type...", arr.dtype) Get the dimensions of ... Read More

Return the base 10 logarithm of the input array element-wise in Numpy

AmitDiwan
Updated on 08-Feb-2022 10:03:06

1K+ Views

To return the base 10 logarithm of the input array, element-wise, use the numpy.log10() method in Python Numpy. For real-valued input data types, log10 always returns real output. For each value that cannot be expressed as a real number or infinity, it yields nan and sets the invalid floating point error flag.Returns the logarithm to the base 10 of x, element-wise. NaNs are returned where x is negative. This is a scalar if x is a scalar.The out is a location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If ... Read More

Compute the Heaviside step function in Numpy

AmitDiwan
Updated on 08-Feb-2022 10:00:38

613 Views

To compute the Heaviside step function, use the numpy.heaviside() method in Python Numpy. The 1st parameter is the input array. The 2nd parameter is the value of the function when array element is 0. Returns the output array, element-wise Heaviside step function of x1. This is a scalar if both x1 and x2 are scalars.The Heaviside step function is defined as −0 if x1 < 0 heaviside(x1, x2) = x2 if x1 == 0 1 if x1 > 0where x2 is often taken to be 0.5, but 0 and 1 are also sometimes used.StepsAt first, import the required library −import ... Read More

Return an element-wise indication of the sign of complex types in Numpy

AmitDiwan
Updated on 08-Feb-2022 09:57:26

124 Views

To return an element-wise indication of the sign of complex types, use the numpy.sign() method in Python Numpy.The sign function returns -1 if x < 0, 0 if x==0, 1 if x > 0. nan is returned for nan inputs. For complex inputs, the sign function returns sign(x.real) + 0j if x.real != 0 else sign(x.imag) + 0j.The complex(nan, 0) is returned for complex nan inputs. There is more than one definition of sign in common use for complex numbers. The definition used here is equivalent to x/x*x which is different from a common alternative, x/|x|.StepsAt first, import the required ... Read More

Return an element-wise indication of the sign of a number in Numpy

AmitDiwan
Updated on 08-Feb-2022 09:55:11

198 Views

To return an element-wise indication of the sign of a number, use the numpy.sign() method in Python Numpy.The sign function returns -1 if x < 0, 0 if x==0, 1 if x > 0. nan is returned for nan inputs. For complex inputs, the sign function returns sign(x.real) + 0j if x.real != 0 else sign(x.imag) + 0j.The complex(nan, 0) is returned for complex nan inputs. There is more than one definition of sign in common use for complex numbers. The definition used here is equivalent to x/x*x which is different from a common alternative, x/|x|.StepsAt first, import the required ... Read More

Round elements of the array to the nearest integer in Numpy

AmitDiwan
Updated on 08-Feb-2022 09:52:37

7K+ Views

To round elements of the array to the nearest integer, use the numpy.rint() method in Python Numpy. For values exactly halfway between rounded decimal values, NumPy rounds to the nearest even value.The out is a location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.The condition is broadcast over the input. At locations where the condition is True, the out array will be set ... Read More

Calculate the absolute value of complex numbers in Numpy

AmitDiwan
Updated on 08-Feb-2022 09:50:38

1K+ Views

To return the absolute value of complex values, use the numpy.absolute() method in Python Numpy. The out is a location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.The condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if ... Read More

Calculate the absolute value of float values in Numpy

AmitDiwan
Updated on 08-Feb-2022 09:49:04

580 Views

To return the absolute value of float values, use the numpy.fabs() method in Python Numpy. This function returns the absolute values (positive magnitude) of the data in x. Complex values are not handled, use absolute to find the absolute values of complex data.The out is a location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.StepsAt first, import the required library −import numpy as ... Read More

Return the element-wise remainder of division with modulo operation in Numpy

AmitDiwan
Updated on 08-Feb-2022 09:45:49

333 Views

To return the element-wise remainder of division with mod operation, use the numpy.mod() method in Python Numpy. Here, the 1st parameter is the Dividend array. The 2nd parameter is the Divisor array.Computes the remainder complementary to the floor_divide function. It is equivalent to the Python modulus operator "x1 % x2" and has the same sign as the divisor x2. The MATLAB function equivalent to np.remainder is mod.StepsAt first, import the required library −import numpy as npCreate an array. This is the dividend array −arr = np.array([3, 9, 14, 22, 76, 81, 91]) Display the array −print("Array...", arr)Get the type of ... Read More

Return the remainder of division with dividend and divisor array-like in Numpy

AmitDiwan
Updated on 08-Feb-2022 09:43:17

99 Views

To return the element-wise remainder of division, use the numpy.remainder() method in Python Numpy. Here, the 1st parameter is the Dividend array. The 2nd parameter is the Divisor array. Computes the remainder complementary to the floor_divide function. It is equivalent to the Python modulus operator "x1 % x2" and has the same sign as the divisor x2. The MATLAB function equivalent to np.remainder is mod.The out is a location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible ... Read More

Advertisements