开始使用免费开始使用

绘制正态分布

某连锁餐厅收集了顾客消费数据。数据显示消费额近似服从正态分布,平均值为 $3.15,标准差为每位顾客 $1.50。

本练习是课程的一部分

Python 概率基础

查看课程

练习说明

  • scipy.stats 导入 norm,将 matplotlib.pyplot 导入为 plt,并将 seaborn 导入为 sns
  • 生成一个均值为 3.15、标准差为 1.5 的正态分布样本。
  • 绘制生成的样本。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Import norm, matplotlib.pyplot, and seaborn
from scipy.stats import ____
import matplotlib.pyplot as ____
import seaborn as ____

# Create the sample using norm.rvs()
sample = norm.____(loc=____, scale=____, size=10000, random_state=13)

# Plot the sample
sns.____(____)
plt.show()
编辑并运行代码