Hướng dẫn log base 2 python numpy - đăng nhập cơ sở 2 python numpy

numpy.log2 (x, /, out = none, *, where = true, casting = 'giống nhaulog2(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])= 'log2'>#

Logarit cơ sở-2 của x.

Tham số xarray_likexarray_like

Giá 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, optional

Mộ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.

**kwargs

Đố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.

Returnsyndarrayyndarray

Logarit 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
  • Bàn luận
  • 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.0
    
    9
    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
    
    1
    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.0
    
    6

    Đầ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

    log26log27nan8

    log29

    >>> 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])
    
    00nan8

    >>> 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])
    
    03nan8

    >>> 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.        ]

    Hướng dẫn log base 2 python numpy - đăng nhập cơ sở 2 python numpy

    Tài liệu tham khảo: https: //docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.exp.html.
    https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.exp.html
    .