- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
受此启发question ,你如何在python中制作相同类型的情节?该图旨在以直观的方式展示您的分布如何偏离预期分布。它将直方图的条形卡在预期分布线上,因此与预期值的差异是在条形底部和 x 轴之间读取的,而不是在条形顶部和预期分布曲线之间读取的。
我找不到任何内置函数。
最佳答案
想法是移动直方图的每个条形图,使条形图的顶部位于预期值处:
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.mlab as mlab
fig, ax = plt.subplots(1, 2)
mu = 10
sig = 0.3
my_data = np.random.normal(mu, sig, 200)
x = np.linspace(9, 11, 100)
# I plot the data twice, one for the histogram only for comparison,
# and one for the rootogram.
# The trick will be to modify the histogram to make it hang to
# the expected distribution curve:
for a in ax:
a.hist(my_data, normed=True)
a.plot(x, mlab.normpdf(x, mu, sig))
a.set_ylim(-0.2)
a.set_xlim(9, 11)
a.hlines(0, 9, 11, linestyle="--")
for rectangle in ax[1].patches:
# expected value in the middle of the bar
exp = mlab.normpdf(rectangle.get_x() + rectangle.get_width()/2., mu, sig)
# difference to the expected value
diff = exp - rectangle.get_height()
rectangle.set_y(diff)
ax[1].plot(rectangle.get_x() + rectangle.get_width()/2., exp, "ro")
ax[0].set_title("histogram")
ax[1].set_title("hanging rootogram")
plt.tight_layout()
给出:
HTH
关于python - 如何在 python 中绘制悬挂根图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38252879/
我试图使用 2 个文件描述符让父级向子级发送信息,并让子级将其发回。 #include #include #include #define READ 0 #define WRITE 1 int
我需要摆脱警告,其中之一是 -Wdangling-else。它在以下宏定义中记录了一个悬空 if: #define FOR_EACH_REF(var, container) \ if(bool
我使用eclipse进行php开发。我最近遇到了一个问题,IDE 会挂起,并且每当我打开 eclipse 时就会立即返回挂起状态。它说它卡在“初始化Java工具”上。我重新安装了多个版本的java和e
我想使用队列来保存结果,因为我希望消费者(串行而不是并行)在工作人员产生结果时处理工作人员的结果。 现在,我想知道为什么以下程序挂起。 import multiprocessing as mp imp
我是 ruby/rails 的新手,过去 2 天一直被一个问题搞得头晕目眩,希望这个论坛上的人能帮助我解决这个问题。 我正在使用 Rails 4 并使用 Passenger + Nginx 和 M
在堆上释放内存后 - vector 中仍保留(悬空)指针。如何完全删除 vector 元素? vector obstacles; vector actions; void Game::free(Ga
在编译器构造中,主要的歧义问题之一是dangling else。正如 Aho、Lam、Sethi 和 Ullman 在《编译器:原理、技术和工具》一书中提到的,悬空 else 的语法不能与 LL(1)
细节: ? Workspace name (e.g., org name) swag
我是一名优秀的程序员,十分优秀!