บทนำ
การประเมินอนุกรม Hermite_e ที่จุด x ใช้เมธอด hermite.hermeval() ใน NumPy พารามิเตอร์ x หากเป็น list/tuple แปลงเป็น ndarray มิฉะนั้นเป็น scalar พารามิเตอร์ C เป็นอาร์เรย์สัมประสิทธิ์ เรียงตามดีกรี พารามิเตอร์ tensor ควบคุมการขยายรูปร่าง (default=True)
ขั้นตอนการทำงาน
1. นำเข้าไลบรารี
import numpy as np from numpy.polynomial import hermite_e as H
2. สร้างอาร์เรย์สัมประสิทธิ์
c = np.array([1, 2, 3])
3. แสดงอาร์เรย์
print("Our Array...\n", c)
4. ตรวจสอบมิติ
print("\nDimensions of our Array...\n", c.ndim)
5. ตรวจสอบชนิดข้อมูล
print("\nDatatype of our Array object...\n", c.dtype)
6. ตรวจสอบรูปร่าง
print("\nShape of our Array object...\n", c.shape)
7. ประเมินอนุกรมที่จุด x=1
print("\nResult...\n", H.hermeval(1, c))
ตัวอย่างโค้ดสมบูรณ์
import numpy as np
from numpy.polynomial import hermite_e as H
c = np.array([1, 2, 3])
print("Our Array...\n", c)
print("\nDimensions of our Array...\n", c.ndim)
print("\nDatatype of our Array object...\n", c.dtype)
print("\nShape of our Array object...\n", c.shape)
print("\nResult...\n", H.hermeval(1, c))
ผลลัพธ์ที่คาดหวัง
Our Array... [1 2 3] Dimensions of our Array... 1 Datatype of our Array object... int64 Shape of our Array object... (3,) Result... 3.0