为什么 scipy.norm.pdf 有时会给出 PDF >1?如何纠正? [英] Why does scipy.norm.pdf sometimes give PDF > 1? How to correct it?

查看:19
本文介绍了为什么 scipy.norm.pdf 有时会给出 PDF >1?如何纠正?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定高斯(正态)随机变量的均值和方差,我想计算其概率密度函数 (PDF).

我参考了这篇文章:

怎么可能有 200% 的概率得到平均值 1.075?我在这里误解了什么吗?有什么办法可以纠正吗?

解决方案

这不是错误.这也不是错误的结果.某个特定点的概率密度函数值不会给你概率;它衡量分布围绕该值的密集.对于连续随机变量,给定点的概率为零.代替 p(X = x),我们计算 2 个点之间的概率 p(x1 并且它等于低于该概率密度的区域功能.概率密度函数的值可以很好地在1以上,甚至可以接近无穷大.

Given mean and variance of a Gaussian (normal) random variable, I would like to compute its probability density function (PDF).

I referred this post: Calculate probability in normal distribution given mean, std in Python,

Also the scipy docs: scipy.stats.norm

But when I plot a PDF of a curve, the probability exceeds 1! Refer to this minimum working example:

import numpy as np
import scipy.stats as stats

x = np.linspace(0.3, 1.75, 1000)
plt.plot(x, stats.norm.pdf(x, 1.075, 0.2))
plt.show()

This is what I get:

How is it even possible to have 200% probability to get the mean, 1.075? Am I misinterpreting anything here? Is there any way to correct this?

解决方案

It's not a bug. It's not an incorrect result either. Probability density function's value at some specific point does not give you probability; it is a measure of how dense the distribution is around that value. For continuous random variables, the probability at a given point is equal to zero. Instead of p(X = x), we calculate probabilities between 2 points p(x1 < X < x2) and it is equal to the area below that probability density function. Probability density function's value can very well be above 1. It can even approach to infinity.

这篇关于为什么 scipy.norm.pdf 有时会给出 PDF &gt;1?如何纠正?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆