离散连续概率分布 [英] Discretizing a continuous probability distribution
问题描述
认识到这可能是一个与编码问题一样多的统计问题,假设我有一个使用 Distributions.jl 创建的正态分布:
Recognizing that this may be as much a statistical question as a coding question, let's say I have a normal distribution created using Distributions.jl:
using Distributions
mydist = Normal(0, 0.2)
是否有一种好的、直接的方法可以让我对这样的分布进行离散化以获得 PMF 而不是 PDF?
Is there a good, straightforward way that I should go about discretizing such a distribution in order to get a PMF as opposed to a PDF?
在 R 中,我发现 actuar 包包含一个离散连续分布的函数.我没有为 Julia 找到类似的东西,但我想在自己动手之前先看看这里.
In R, I found that the actuar package contains a function to discretize a continuous distribution. I failed to find anything similar for Julia, but thought I'd check here before rolling my own.
推荐答案
没有内置函数可以做到这一点,但你可以使用范围对象,结合 cdf
和 diff
计算值的函数:
There isn't an inbuilt function to do it, but you can use a range object, combined with the cdf
and diff
functions to compute the values:
using Distributions
mydist = Normal(0, 0.2)
r = -3:0.1:3
d = diff(cdf(mydist, r))
这篇关于离散连续概率分布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!