3

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.

Peter
  • 4,219
  • 4
  • 28
  • 40
  • When you say discretize what do you mean? Do you want to end up with something like a Markov chain that approximates the distribution? – spencerlyon2 Jun 20 '14 at 00:30

1 Answers1

8

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))
Simon Byrne
  • 7,694
  • 1
  • 26
  • 50