从Python中的垃圾箱产生潜在的分布

发布于 2025-01-28 05:57:55 字数 347 浏览 3 评论 0原文

我发现了一份PDF文件,描述了1978年美国的收入分配。每个收入范围我的人口百分比属于该收入范围。我想在Python中产生基础分布。数据看起来像这样:

under 3000$: 6.2%
$3000-4999$: 8.5%
$5000-$6999: 7.6%

,请参阅屏幕截图以获取更详细的描述。

“收入bins”

我找到了函数scipy.stats.rv_histargram直方图,但我不确定如何创建此初始直方图。

I found a PDF document describing the income distribution in the US in 1978. Per income range I have the percentage of the population that falls in that income range. I'd like to generate the underlying distribution in python. The data looks something like this:

under 3000$: 6.2%
$3000-4999$: 8.5%
$5000-$6999: 7.6%

etc

See the screenshot for a more detailed description.

Income bins

I've found the function scipy.stats.rv_histogram that generates a distribution given a histogram, but I'm not sure how to create this initial histogram.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

耳钉梦 2025-02-04 05:57:55

请参阅
它明确指出:

参数:
直方图: andRay_like
的元组
包含两个array_like对象的元组包含n个bin的含量的第二个包含(n+1)bin边界的第二个bin的含量,特别是返回值np。组织图被接受

您可以创建直方图,例如:

import scipy.stats
import numpy as np

total_number = 77330
prob = np.array([6.2, 8.5, 7.6, 10.8, 7.1, 9.6, 15.3, 12.2, 22.7])
data = prob*total_number
bin_boundary = np.array([0, 3000, 5000, 7000, 10000, 12000, 15000, 20000, 25000, 1e7])

hist = (data, bin_boundary)
hist_dist = scipy.stats.rv_histogram(hist)

Refer the documentation for scipy.stats.rv_histogram
it clearly states that:

Parameters:
histogram: tuple of array_like
Tuple containing two array_like objects The first containing the content of n bins The second containing the (n+1) bin boundaries In particular the return value np.histogram is accepted

You can create the histogram like:

import scipy.stats
import numpy as np

total_number = 77330
prob = np.array([6.2, 8.5, 7.6, 10.8, 7.1, 9.6, 15.3, 12.2, 22.7])
data = prob*total_number
bin_boundary = np.array([0, 3000, 5000, 7000, 10000, 12000, 15000, 20000, 25000, 1e7])

hist = (data, bin_boundary)
hist_dist = scipy.stats.rv_histogram(hist)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文