Logarit cơ sở-2 của x.
Tham số xarray_likexarray_likeGiá trị đầu vào.
outndarray, không có, hoặc tuple của ndarray và không có, tùy chọnndarray, None, or tuple of ndarray and None, optionalMột vị trí mà kết quả được lưu trữ. Nếu được cung cấp, nó phải có một hình dạng mà các đầu vào phát sóng. Nếu không được cung cấp hoặc không có, một mảng mới được phân bổ được trả lại. Một tuple [chỉ có thể là đối số từ khóa] phải có độ dài bằng số lượng đầu ra.
wherearray_like, tùy chọnarray_like, optionalĐiều kiện này được phát trên đầu vào. Tại các vị trí mà điều kiện là đúng, mảng ra sẽ được đặt thành kết quả UFUNC. Ở những nơi khác, mảng ra sẽ giữ lại giá trị ban đầu của nó. Lưu ý rằng nếu một mảng ra không được tạo ra được tạo thông qua out=None
mặc định, các vị trí trong đó điều kiện là sai sẽ vẫn không được cung cấp.
Đối với các đối số chỉ từ khóa khác, hãy xem các tài liệu UFUNC.ufunc docs.
ReturnsyndarrayyndarrayLogarit cơ sở-2 của x. Đây là vô hướng nếu X là vô hướng.
Ghi chú
Mới trong phiên bản 1.3.0.
Logarit là một hàm đa trị: đối với mỗi x có một số lượng vô hạn z sao cho 2 ** z = x. Công ước là trả lại Z có phần tưởng tượng nằm trong [-Pi, pi].
Đối với các loại dữ liệu đầu vào có giá trị thực, log2
luôn trả về đầu ra thực. Đối với mỗi giá trị không thể được biểu thị dưới dạng một số thực hoặc vô cực, nó mang lại nan
và đặt cờ lỗi điểm nổi không hợp lệ.
Đối với đầu vào có giá trị phức tạp, log2
là một hàm phân tích phức tạp có cắt nhánh [-inf, 0] và liên tục từ trên cao. log2
xử lý số 0 âm điểm nổi dưới dạng số âm vô hạn, phù hợp với tiêu chuẩn C99.
Ví dụ
>>> x = np.array[[0, 1, 2, 2**4]] >>> np.log2[x] array[[-Inf, 0., 1., 4.]]
>>> xi = np.array[[0+1.j, 1, 2+0.j, 4.j]] >>> np.log2[xi] array[[ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j]]
Cải thiện bài viết
Lưu bài viết
Cải thiện bài viết
Lưu bài viết
Đọc
This mathematical function helps user to calculate Base-2 logarithm of
x where x belongs to all the input array elements.
Bàn luận
array : [array_like]Input array or object. out : [ndarray, optional]Output array with same dimensions as Input array, placed with result. **kwargs : Allows you to pass keyword variable length of argument to a function. It is used when we want to handle named argument in a function. where : [array_like, optional]True value means to calculate the universal functions[ufunc] at that position, False value means to leave the value in the output alone.
numpy.log2 [mảng, out = none, *, where = true, casting = 'giống nhau x trong đó x thuộc về tất cả các phần tử mảng đầu vào.
An array with Base-2 logarithmic value of x; where x belongs to all elements of input array.
Thông số :
Trở về :
Mã 1: Làm việc
>>> xi = np.array[[0+1.j, 1, 2+0.j, 4.j]] >>> np.log2[xi] array[[ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j]]1
>>> xi = np.array[[0+1.j, 1, 2+0.j, 4.j]] >>> np.log2[xi] array[[ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j]]2
>>> xi = np.array[[0+1.j, 1, 2+0.j, 4.j]] >>> np.log2[xi] array[[ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j]]3
>>> xi = np.array[[0+1.j, 1, 2+0.j, 4.j]] >>> np.log2[xi] array[[ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j]]4
>>> xi = np.array[[0+1.j, 1, 2+0.j, 4.j]] >>> np.log2[xi] array[[ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j]]5
>>> xi = np.array[[0+1.j, 1, 2+0.j, 4.j]] >>> np.log2[xi] array[[ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j]]6
>>> xi = np.array[[0+1.j, 1, 2+0.j, 4.j]] >>> np.log2[xi] array[[ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j]]7
>>> xi = np.array[[0+1.j, 1, 2+0.j, 4.j]] >>> np.log2[xi] array[[ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j]]8__
array : [array_like]Input array or object. out : [ndarray, optional]Output array with same dimensions as Input array, placed with result. **kwargs : Allows you to pass keyword variable length of argument to a function. It is used when we want to handle named argument in a function. where : [array_like, optional]True value means to calculate the universal functions[ufunc] at that position, False value means to leave the value in the output alone.7
array : [array_like]Input array or object. out : [ndarray, optional]Output array with same dimensions as Input array, placed with result. **kwargs : Allows you to pass keyword variable length of argument to a function. It is used when we want to handle named argument in a function. where : [array_like, optional]True value means to calculate the universal functions[ufunc] at that position, False value means to leave the value in the output alone.8
array : [array_like]Input array or object. out : [ndarray, optional]Output array with same dimensions as Input array, placed with result. **kwargs : Allows you to pass keyword variable length of argument to a function. It is used when we want to handle named argument in a function. where : [array_like, optional]True value means to calculate the universal functions[ufunc] at that position, False value means to leave the value in the output alone.9
An array with Base-2 logarithmic value of x; where x belongs to all elements of input array.0
An array with Base-2 logarithmic value of x; where x belongs to all elements of input array.1
>>> xi = np.array[[0+1.j, 1, 2+0.j, 4.j]] >>> np.log2[xi] array[[ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j]]4
An array with Base-2 logarithmic value of x; where x belongs to all elements of input array.3
array : [array_like]Input array or object. out : [ndarray, optional]Output array with same dimensions as Input array, placed with result. **kwargs : Allows you to pass keyword variable length of argument to a function. It is used when we want to handle named argument in a function. where : [array_like, optional]True value means to calculate the universal functions[ufunc] at that position, False value means to leave the value in the output alone.7
array : [array_like]Input array or object. out : [ndarray, optional]Output array with same dimensions as Input array, placed with result. **kwargs : Allows you to pass keyword variable length of argument to a function. It is used when we want to handle named argument in a function. where : [array_like, optional]True value means to calculate the universal functions[ufunc] at that position, False value means to leave the value in the output alone.8
Input array : [1, 3, 5, 256] Output array : [ 0. 1.5849625 2.32192809 8. ] np.log2[4**4] : 8.0 np.log2[2**8] : 8.09
Input array : [1, 3, 5, 256] Output array : [ 0. 1.5849625 2.32192809 8. ] np.log2[4**4] : 8.0 np.log2[2**8] : 8.01
array : [array_like]Input array or object. out : [ndarray, optional]Output array with same dimensions as Input array, placed with result. **kwargs : Allows you to pass keyword variable length of argument to a function. It is used when we want to handle named argument in a function. where : [array_like, optional]True value means to calculate the universal functions[ufunc] at that position, False value means to leave the value in the output alone.2
array : [array_like]Input array or object. out : [ndarray, optional]Output array with same dimensions as Input array, placed with result. **kwargs : Allows you to pass keyword variable length of argument to a function. It is used when we want to handle named argument in a function. where : [array_like, optional]True value means to calculate the universal functions[ufunc] at that position, False value means to leave the value in the output alone.3
array : [array_like]Input array or object. out : [ndarray, optional]Output array with same dimensions as Input array, placed with result. **kwargs : Allows you to pass keyword variable length of argument to a function. It is used when we want to handle named argument in a function. where : [array_like, optional]True value means to calculate the universal functions[ufunc] at that position, False value means to leave the value in the output alone.3
array : [array_like]Input array or object. out : [ndarray, optional]Output array with same dimensions as Input array, placed with result. **kwargs : Allows you to pass keyword variable length of argument to a function. It is used when we want to handle named argument in a function. where : [array_like, optional]True value means to calculate the universal functions[ufunc] at that position, False value means to leave the value in the output alone.5
Input array : [1, 3, 5, 256] Output array : [ 0. 1.5849625 2.32192809 8. ] np.log2[4**4] : 8.0 np.log2[2**8] : 8.06
Đầu ra:
Input array : [1, 3, 5, 256] Output array : [ 0. 1.5849625 2.32192809 8. ] np.log2[4**4] : 8.0 np.log2[2**8] : 8.0
array : [array_like]Input array or object. out : [ndarray, optional]Output array with same dimensions as Input array, placed with result. **kwargs : Allows you to pass keyword variable length of argument to a function. It is used when we want to handle named argument in a function. where : [array_like, optional]True value means to calculate the universal functions[ufunc] at that position, False value means to leave the value in the output alone.7
array : [array_like]Input array or object. out : [ndarray, optional]Output array with same dimensions as Input array, placed with result. **kwargs : Allows you to pass keyword variable length of argument to a function. It is used when we want to handle named argument in a function. where : [array_like, optional]True value means to calculate the universal functions[ufunc] at that position, False value means to leave the value in the output alone.8
An array with Base-2 logarithmic value of x; where x belongs to all elements of input array.6
An array with Base-2 logarithmic value of x; where x belongs to all elements of input array.7
Code 2 : Graphical representation
Trở về :
Mã 1: Làm việc
>>> xi = np.array[[0+1.j, 1, 2+0.j, 4.j]] >>> np.log2[xi] array[[ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j]]1
>>> xi = np.array[[0+1.j, 1, 2+0.j, 4.j]] >>> np.log2[xi] array[[ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j]]2
>>> xi = np.array[[0+1.j, 1, 2+0.j, 4.j]] >>> np.log2[xi] array[[ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j]]3
>>> xi = np.array[[0+1.j, 1, 2+0.j, 4.j]] >>> np.log2[xi] array[[ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j]]4
>>> xi = np.array[[0+1.j, 1, 2+0.j, 4.j]] >>> np.log2[xi] array[[ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j]]5
>>> xi = np.array[[0+1.j, 1, 2+0.j, 4.j]] >>> np.log2[xi] array[[ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j]]6
>>> xi = np.array[[0+1.j, 1, 2+0.j, 4.j]] >>> np.log2[xi] array[[ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j]]7
>>> xi = np.array[[0+1.j, 1, 2+0.j, 4.j]] >>> np.log2[xi] array[[ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j]]8__
array : [array_like]Input array or object. out : [ndarray, optional]Output array with same dimensions as Input array, placed with result. **kwargs : Allows you to pass keyword variable length of argument to a function. It is used when we want to handle named argument in a function. where : [array_like, optional]True value means to calculate the universal functions[ufunc] at that position, False value means to leave the value in the output alone.7
array : [array_like]Input array or object. out : [ndarray, optional]Output array with same dimensions as Input array, placed with result. **kwargs : Allows you to pass keyword variable length of argument to a function. It is used when we want to handle named argument in a function. where : [array_like, optional]True value means to calculate the universal functions[ufunc] at that position, False value means to leave the value in the output alone.8
array : [array_like]Input array or object. out : [ndarray, optional]Output array with same dimensions as Input array, placed with result. **kwargs : Allows you to pass keyword variable length of argument to a function. It is used when we want to handle named argument in a function. where : [array_like, optional]True value means to calculate the universal functions[ufunc] at that position, False value means to leave the value in the output alone.9
An array with Base-2 logarithmic value of x; where x belongs to all elements of input array.0
An array with Base-2 logarithmic value of x; where x belongs to all elements of input array.1
>>> xi = np.array[[0+1.j, 1, 2+0.j, 4.j]] >>> np.log2[xi] array[[ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j]]4
An array with Base-2 logarithmic value of x; where x belongs to all elements of input array.3
array : [array_like]Input array or object. out : [ndarray, optional]Output array with same dimensions as Input array, placed with result. **kwargs : Allows you to pass keyword variable length of argument to a function. It is used when we want to handle named argument in a function. where : [array_like, optional]True value means to calculate the universal functions[ufunc] at that position, False value means to leave the value in the output alone.7
array : [array_like]Input array or object. out : [ndarray, optional]Output array with same dimensions as Input array, placed with result. **kwargs : Allows you to pass keyword variable length of argument to a function. It is used when we want to handle named argument in a function. where : [array_like, optional]True value means to calculate the universal functions[ufunc] at that position, False value means to leave the value in the output alone.8
An array with Base-2 logarithmic value of x; where x belongs to all elements of input array.6
An array with Base-2 logarithmic value of x; where x belongs to all elements of input array.7
log2
6log2
7nan
8
log2
9
>>> xi = np.array[[0+1.j, 1, 2+0.j, 4.j]] >>> np.log2[xi] array[[ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j]]00
nan
8>>> xi = np.array[[0+1.j, 1, 2+0.j, 4.j]] >>> np.log2[xi] array[[ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j]]02
>>> xi = np.array[[0+1.j, 1, 2+0.j, 4.j]] >>> np.log2[xi] array[[ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j]]03
nan
8>>> xi = np.array[[0+1.j, 1, 2+0.j, 4.j]] >>> np.log2[xi] array[[ 0.+2.26618007j, 0.+0.j , 1.+0.j , 2.+2.26618007j]]05
Đầu ra:
out_array : [ 0. 0.26303441 0.48542683 0.67807191 0.84799691 1. ]
Tài liệu tham khảo: //docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.exp.html.
//docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.exp.html
.