在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]
广告