第1关:使用函数值填充列表
import math
import numpy as np
from math import *
class Solution:
def solve(self, s, e):
"""
:type s, e: int, int
:rtype: list
"""
#请在此按照“编程要求”填写代码
#********** Begin *********#
xlist=[]
d=(e-s)/40.0
a=[i for i in np.arange(s,e+0.000001,d)]
for x in a:
hx=(1/math.sqrt(2*math.pi))*math.exp(x*x*(-1/2))
xlist.append(hx)
return xlist
##********** End **********#
第2关:填充数组(循环版本)
import numpy as np
import math
class Solution:
def solve(self, s, e

这个系列涵盖了使用Python进行数学函数的计算与绘图,包括使用函数值填充列表、循环与向量化填充数组、绘制二维函数图形、函数作用于向量以及手动模拟执行向量表达式。示例中使用了numpy和matplotlib等库,展示了在数值计算和科学可视化中的基本操作。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



