1 Star 0 Fork 51

花大虫张/Book5_Essentials-of-Probability-and-Statistics

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Bk5_Ch05_01.py 627 Bytes
一键复制 编辑 原始数据 按行查看 历史
Visualize-ML 提交于 2022-11-28 23:58 +08:00 . Add files via upload
###############
# Authored by Weisheng Jiang
# Book 5 | From Basic Arithmetic to Machine Learning
# Published and copyrighted by Tsinghua University Press
# Beijing, China, 2022
###############
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import randint
a = 1
b = 6
x = np.arange(a, b+1)
discrete_uniform = randint(a, b+1)
p_x = discrete_uniform.pmf(x)
E_x = np.sum(p_x*x)
fig, ax = plt.subplots()
plt.stem(x, p_x)
plt.axvline(x = E_x, color = 'r', linestyle = '--')
plt.xticks(np.arange(a,b+1))
plt.xlabel('x')
plt.ylabel('PMF, $p_X(x)$')
plt.ylim([0,0.2])
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/hua-da-chong-zhang/Book5_Essentials-of-Probability-and-Statistics.git
git@gitee.com:hua-da-chong-zhang/Book5_Essentials-of-Probability-and-Statistics.git
hua-da-chong-zhang
Book5_Essentials-of-Probability-and-Statistics
Book5_Essentials-of-Probability-and-Statistics
main

搜索帮助