0
$\begingroup$

I have implemented what I believe to be a sampler from a distribution over the integers. Its a specific discretization of the normal distribution so I know stuff like mean and variance of the theoretical distribution, and I can compute an approximate of the theoretical pmf but it's expensive so I can't do it for a lot of values. I'd like to gain some confidence that my sampler is actually sampling from the right distribution, preferably in a reproducible way (so no looking at histograms etc). what's a reasonable test for this?

I'm mostly overwhelmed by the variety of available statistics and the search for one that is defined for discrete distributions yet tells me something about "normality".

$\endgroup$
16
  • $\begingroup$ Could you explain what might be "expensive" about computing the PMF? It could only be if you have millions of integers with appreciable probabilities, in which case you can replace the PMF by the Normal density to very great accuracy. If you just want to test the accuracy of your sampler, what's the matter with the standard Chi-squared test? $\endgroup$
    – whuber
    Commented Jul 27, 2023 at 17:22
  • 1
    $\begingroup$ @whuber You've anticipated that I meant what is sometimes termed the "significance level", but I should have indicated that for clarity. It is that very notion of 'acceptable' which seems nebulous to me without assigning it to be coupled to something non-arbitrary. I guess the OP will have to decide what they find acceptable. $\endgroup$
    – Galen
    Commented Jul 27, 2023 at 17:53
  • 1
    $\begingroup$ @Galen The most general concept of discretization I have run across is tantamount to a measurable transformation $h:[a,b]\to\mathcal D$ where $[a,b]$ is the support of a distribution $F$ and $\mathcal D$ is a discrete subset of real numbers. The discretization $[F]_h$ of $F$ has $\mathcal D$ for its support and for all $d\in\mathcal D,$ ${\Pr}_{[F]_h}(d)=\Pr(h(X)=d).$ (Always $h$ is monotonic, but it needn't be.) Thus, calculating these probabilities comes down to a calculation using $F.$ But whether anything like this is meant is a matter of speculation, because we haven't been told. $\endgroup$
    – whuber
    Commented Jul 27, 2023 at 20:19
  • 1
    $\begingroup$ Although the normalizing constant might be defined in terms of a sum (much as, say, the exponential function is defined as a sum), you don't need that sum to compute it. It is expressible in terms of a Jacobi Theta function, whose properties are well studied. Moreover, unless $\sigma$ is huge, there will be such a small number of terms in the sum that it can be approximated quickly with great accuracy with a finite partial sum. Just summing over $y$ for which $|y-\mu|\le 8\sigma,$ for instance, gives double precision results. This is why details matter! $\endgroup$
    – whuber
    Commented Jul 27, 2023 at 21:05
  • 1
    $\begingroup$ BTW, I believe a natural and extremely efficient method to sample from this distribution would use rejection sampling from the (obvious) dominating Gaussian distribution. $\endgroup$
    – whuber
    Commented Jul 27, 2023 at 21:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.