我必須在一個回圈中創建一個串列,其中包括 z range(0,200) 的高斯函式
def GetDepth():
return float(a * 2.7 - (z - mu)**2 / (2 * sig**2))
for z in range(-1,200):
k =[]
z=z 1;
for i in range(1):
k.append(z);
Gauss_list.append([z]);
Gauss_list.append([GetDepth()]);
print(Gauss_list)
它回傳如下內容:
[[0], [-1.0535849715692442], [1], [-0.8792864705363532], [2], [-0.7109879179039058], [3], [-0.5486893136719024], [4], [-0.39239065784034244]....
但我需要的是:
[[0, -1.0535849715692442], [1,-0.8792864705363532], [2,-0.7109879179039058], [3,-0.5486893136719024]....
那是針對高斯圖的。也許還有另一種選擇可以在不制作二元串列的情況下制作情節?
uj5u.com熱心網友回復:
代替:
Gauss_list.append([z]);
Gauss_list.append([GetDepth()]);
立即使用append:
Gauss_list.append([z, GetDepth()])
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/327226.html
上一篇:創建具有相同鍵的字典串列
