在Python中返回在x的每個元素處計算的修正貝塞爾函式
要返回在x的每個元素處計算的修正貝塞爾函式,請使用numpy.io()方法。引數x是貝塞爾函式的自變數。該方法返回在x的每個元素處計算的修正貝塞爾函式。(**注意:原文中`numpy.io()`方法可能存在錯誤,numpy中沒有直接計算修正貝塞爾函式的`io()`方法,可能是`scipy.special.iv()`或類似函式。此處保留原文,但需讀者注意)**
步驟
首先,匯入所需的庫:
import numpy as np
使用array()方法建立一個數組:
arr = np.array([10, 20, 30, 40, 50])
顯示陣列:
print("Array...
", arr)獲取陣列的型別:
print("
Our Array type...
", arr.dtype)
獲取陣列的維度:
print("
Our Array Dimension...
",arr.ndim)獲取陣列的形狀:
print("
Our Array Shape...
",arr.shape)
要返回在x的每個元素處計算的修正貝塞爾函式,請使用numpy.io()方法 (**注意:此處同第39段,方法名可能錯誤)**:
print("Array...
", np.i0(arr))示例
import numpy as np
# Create an array using the array() method
arr = np.array([10, 20, 30, 40, 50])
# Display the array
print("Array...
", arr)
# Get the type of the array
print("
Our Array type...
", arr.dtype)
# Get the dimensions of the Array
print("
Our Array Dimension...
",arr.ndim)
# Get the shape of the Array
print("
Our Array Shape...
",arr.shape)
# To return the modified Bessel function evaluated at each of the elements of x, use the numpy.io() method
# The parameter x is an Argument of the Bessel function.
# The method returns the modified Bessel function evaluated at each of the elements of x.
print("Array...
", np.i0(arr))輸出
Array... [10 20 30 40 50] Our Array type... int64 Our Array Dimension... 1 Our Array Shape... (5,) Array... [2.81571663e+03 4.35582826e+07 7.81672298e+11 1.48947748e+16 2.93255378e+20]
廣告
資料結構
網路
關係資料庫管理系統 (RDBMS)
作業系統
Java
iOS
HTML
CSS
Android
Python
C語言程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP