编写QQ情节
我有男女学生的数学考试成绩样本。我想为每个性别绘制QQ图,看看每个性别是否服从正态分布。我知道如何绘制整体样本的 QQ 图,但如何单独绘制它们?
I have a sample of math test scores for male and female students. I want to draw QQ plot for each gender to see if each of them is normally distributed. I know how to draw the QQ plot for the overall sample, but how can I draw them separately?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个使用
base
图形的简单解决方案:然后是一个更优雅的
lattice
解决方案:请参阅
qqmath
的在线帮助以获取更多讨论和示例可能的定制。Here is a simple solution using
base
graphics:A more elegant
lattice
solution then:See the on-line help for
qqmath
for more discussion and example of possible customization.在Python中,您有OpenTURNS库提供的QQplot方法 请参阅此处的文档。这是一个例子。
第一步,我们从均匀分布中生成大小为 300 的随机样本。
第二步,我们认为我们不知道这个样本来自哪里,并尝试拟合正态分布和均匀分布。
第三步,我们针对每个拟合分布绘制样本的 QQ 图,以便“查看”哪一个是最好的
第一步:
第二步:
第三步:
正如预期的那样,拟合的均匀分布更适合对域两端误差较大的法线进行采样。
In Python, you have a QQplot method offered by the OpenTURNS Library see doc here. Here is an example.
In a first step, we generate a random sample of size 300 from a Uniform distribution.
In a second step, we consider that we do not know where this sample comes from and try to fit a Normal distribution and a Uniform distribution.
In a third step, we draw the QQPlot of ;the sample against each of the fitted distributions in order to "see" which one is the best
1st step:
2nd step:
3rd step:
As expected, the fitted Uniform is more adapted to the sample the Normal which has bigger error at both ends of the domain.