import numpy as np
import matplotlib.pyplot as plt

# 给定的数列
sequence = [33, -66, 99, -33, 0, 0, 66, -33, 33, 33, -33, 33, 0, 53, -27, 27, 46, -33, 
            366, -933, 966, -333, 66, 0, 0, 33, 66, -66, 66, 33, -33, 66, 33, 0, 0, 66]

# 计算相邻数值的差分
diff = np.diff(sequence)

# 输出差分
print("原数列的差分：", diff)

# 绘制原数列和差分图
plt.figure(figsize=(10, 5))

# 原数列的图像
plt.subplot(1, 2, 1)
plt.plot(sequence, label="原数列")
plt.title("原数列")
plt.xlabel("索引")
plt.ylabel("值")

# 差分图像
plt.subplot(1, 2, 2)
plt.plot(diff, label="差分", color='orange')
plt.title("差分图")
plt.xlabel("索引")
plt.ylabel("差值")

plt.tight_layout()
plt.show()

# 计算数列的其他统计量
mean = np.mean(sequence)
std = np.std(sequence)
print(f"数列的均值: {mean}")
print(f"数列的标准差: {std}")
