Monte Carlo Simulations ใน Python
Izzy Weber
Curriculum Manager, DataCamp
รูประฆังคว่ำ มีจุดศูนย์กลางที่ค่าเฉลี่ย (หรือ loc) และความกว้างกำหนดโดยส่วนเบี่ยงเบนมาตรฐาน (หรือ scale)
ความสูงของผู้ชายวัยผู้ใหญ่ชาวอเมริกันมีการแจกแจงแบบปกติ:




ความสูงของผู้ชายวัยผู้ใหญ่ชาวอเมริกันมีการแจกแจงแบบปกติ; ค่าเฉลี่ย = 177 ซม.; ส่วนเบี่ยงเบนมาตรฐาน = 8 ซม.
ผู้ที่มีความสูงเกิน 190 ซม. หรือต่ำกว่า 165 ซม. คิดเป็นกี่เปอร์เซ็นต์?
heights = st.norm.rvs(loc=177, scale=8, size=10000)qualified = (heights < 165) | (heights > 190)print(np.sum(qualified) * 100/10000)
12.28
heights_dict = {"heights":heights}
sns.histplot(x="heights", data=heights_dict)
plt.axvline(x=165, color="red")
plt.axvline(x=190, color="red")

st.uniform)st.expon)Monte Carlo Simulations ใน Python