1 Star 0 Fork 53

fosterkong/Book5_Essentials-of-Probability-and-Statistics

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Bk5_Ch07_01.py 1.24 KB
一键复制 编辑 原始数据 按行查看 历史
Visualize-ML 提交于 2年前 . 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
import seaborn as sns
a = 0
b = 10
num_data = 500
random_data = np.random.uniform(a,b,num_data)
fig, ax = plt.subplots()
# Plot the histogram
# sns.displot(random_data, bins=20)
sns.histplot(random_data, bins=20, ax = ax)
sns.rugplot(random_data, ax = ax)
plt.xlabel('x')
plt.ylabel('Count')
plt.gca().spines['right'].set_visible(False)
plt.gca().spines['top'].set_visible(False)
plt.gca().yaxis.set_ticks_position('left')
plt.gca().xaxis.set_ticks_position('bottom')
plt.xlim(a,b)
plt.xticks([0,2,4,6,8,10])
fig, ax = plt.subplots()
# Plot empirical cumulative distribution function
# sns.ecdfplot(random_data)
sns.histplot(random_data, bins=20, fill=True,
cumulative=True, stat="density")
plt.xlabel('x')
plt.ylabel('Empirical CDF')
plt.gca().spines['right'].set_visible(False)
plt.gca().spines['top'].set_visible(False)
plt.gca().yaxis.set_ticks_position('left')
plt.gca().xaxis.set_ticks_position('bottom')
plt.xlim(a,b)
plt.xticks([0,2,4,6,8,10])
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/fosterkong/Book5_Essentials-of-Probability-and-Statistics.git
git@gitee.com:fosterkong/Book5_Essentials-of-Probability-and-Statistics.git
fosterkong
Book5_Essentials-of-Probability-and-Statistics
Book5_Essentials-of-Probability-and-Statistics
main

搜索帮助