Reputation: 4359
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.
Upvotes: 3
Views: 1036
Reputation: 7864
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))
Upvotes: 8