Discretizing a continuous probability distribution

岁酱吖の 提交于 2020-01-23 12:20:03

问题


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)

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?

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.


回答1:


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))


来源:https://stackoverflow.com/questions/24317929/discretizing-a-continuous-probability-distribution

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!