python - 将 math.erf 应用于数组
问题描述
我正在使用 math.erf 来查找数组中每个元素的误差函数。
# Import the erf function from the math library
from math import erf
# Import the numpy library to represent the input data
import numpy as np
# Create a dummy np.array
dummy_array = np.arange(20)
# Apply the erf function to the array to calculate the error function of each element
erf_array = erf(dummy_array)
我收到一个错误,因为我无法将整个函数应用于数组。有没有一种方法可以将误差函数应用于整个数组(矢量化方法),而无需遍历每个元素并应用它?(循环会花费很多时间,因为表格会很大)
解决方案
推荐阅读
- amazon-web-services - 使用 Jest 进行 AWS CodeDeploy 蓝绿部署测试?
- webpack - Webpack 5 与 Craft CMS 结合,Twigpack 和 SASS 搞乱了我的背景图片
- linux - 在 Linux VM 上设置持久环境变量并使用 GuestProcessManager.ReadEnvironmentVariableInGuest 方法读取它
- powershell - PowerShell 和 Power BI 休息 API
- php - Docker - 似乎无法让 PDO 驱动程序工作
- rdf - 为什么此 SHACL 验证不能按预期工作?
- rust - 盒装对象的返回向量
- r - R - 带有控制变量的逻辑回归
- python - 删除特定键但不删除 value(list) ,因此它成为上键的元素
- javascript - javascript从CharCode转换为土耳其字符