# Implementing a discrete analogue to Gaussian function [closed]

Given a Gaussian function of the form $$g(x) = ae^{-(x-b)^2/(2c^2)}$$

I am interested in a discrete analogue to this, which deals with the case where $x$ is discrete. As I understand there are two ways of doing this, namely, the Sampled Gaussian kernel and the Discrete Gaussian kernel. Does anyone know how to explain the implementation of these in a simple way or has a good reference for a text or set of notes? I don't have a very strong background in statistics hence I am having difficulty understanding the protocol involved in these two methods.

To give some context: Consider an operator which takes the constants $a,b,c$ to a Gaussian function $$\{a,b,c\} \mapsto ae^{\frac{(x-b)^2}{2c^2}}~~~~~~~(1)$$

Given that $x'$ is discrete and possibly bounded $-N \leq x' \leq N$, is there a discrete case analogue to the operator (1) which gives some Gaussian type distribution given some parameters $a,b,c...$ which include the mean and the variance?

• Since there are many possible (but distinctly different) solutions, we need more information. Could you explain what this discrete function would be used for or how you would interpret it? – whuber Jul 21 '17 at 14:28
• Thank you for trying, but you still haven't described a statistical problem, thereby leaving us without any clues to recommend one solution over another. Your description is abstractly mathematical, apparently devoid of any purpose. Why do you want to define a discrete analog of this operator (a convolution, apparently)? What will you do with it? How will you interpret it? How would it be applied? – whuber Jul 21 '17 at 15:42
• @JohnJack - what is the "business case" for this? What are you going to do with it when you are done? How are you going to measure the success or failure of that thing? – EngrStudent - Reinstate Monica Jul 21 '17 at 15:43
• @wubher The actual application is going to take too long to explain. I just want the question interpreted purely as a statistics query, someone just wondering about the possibilities of defining the mentioned operator. I revised the question to be less muddled. – John Jack Jul 21 '17 at 16:12
• @gung A well-posed question still hasn't appeared and I haven't a clue concerning the statistical setting or proposed application. The references to "include the mean and variance" are obscure, because as far as I can see we aren't even (yet) discussing an actual distribution, but only a Gaussian function. Even if $a$ is chosen to make it one, $c^2$ would not exactly be its variance. As far as I can tell, the latest incarnation of this question asks responders to propose a two- or three-parameter family of "discrete Gaussians," but it provides no further information to guide one to a solution. – whuber Jul 21 '17 at 16:49

Luc Devroye defines a discrete normal in his book (Non-Uniform Random Variate Generation) (pg 117). Here is a link to chapter 3: http://www.nrbook.com/devroye/Devroye_files/chapter_three.pdf last page of chapter 3 is page 117.

$$\Pr(X=i)= c\exp\left[\frac{(|x| +0.5)^2}{2\sigma^2}\right],$$

where $i$ is an integer. The book also gives an algorithm for generating a random variable from this distribution. This would apply for your question if $N\to\infty$.

The most basic way to discretize the continuous probability distribution is to assumed its "rounded" form, i.e. if $X \sim \mathcal{N}(\mu, \sigma)$, then $\lfloor X \rfloor$ follows the discrete analogue. For discrete normal distribution, the probability mass function following from such procedure is

$$f(x) = \Phi\left(\frac{x-\mu+1}{\sigma}\right) - \Phi\left(\frac{x-\mu}{\sigma}\right)$$

where $\Phi$ is standard normal cumulative distribution function, as described in

Roy, D. (2003). The discrete normal distribution. Communications in Statistics-Theory and Methods, 32, 1871-1883.

Alternatively, you may consider rounding within the $\pm0.5$ interval (i.e. distribution of $\lfloor X +0.5\rfloor$).

• Thanks for your answer. Please see my updated question with some context. Would your suggestion be appropriate for this type of application? – John Jack Jul 21 '17 at 15:32

I don't know of any such distribution. The normal distribution runs from negative infinity to positive infinity, so bounds (i.e., $-N$ to $N$) will weaken the analogy to the normal. That said, if I wanted a distribution that seemed this way, for a simulation say, I would sample from a Binomial distribution with $n = 2N$ and $\pi=.5$. Then I would subtract $N$ from all realized values. If you wanted the mean to be anything else, you could use a different value of $\pi$, but you need to recognize that that would weaken the analogy to the normal even further. The population SD of the generated distribution would necessarily be $.5\sqrt{2N}$. You could make that wider if you wanted by sampling the $\pi$ parameter from a narrow, symmetrical distribution around .5, with the wider that distribution of $\pi$s, the higher the resulting SD could be. The distribution then might be a beta binomial.

• I'd love to see an example done. – EngrStudent - Reinstate Monica Jul 21 '17 at 14:30
• @EngrStudent, an example of what, exactly? – gung - Reinstate Monica Jul 21 '17 at 14:52
• I like your answer. I think you are correct. I know its my own crazy, but my best rated answers go end-to-end with a worked example. I think a simple example case, some very simple R-code, and a plot showing the original and the approximation would be useful to folks for a long time. There are a number of times where I search on google, and it takes me to SE and there is a 100+ vote answer from 2013 that does the job. I think those kinds of answers are what make SE great, and are a good professional legacy. – EngrStudent - Reinstate Monica Jul 21 '17 at 14:55
• @EngrStudent, thanks. Can you give me some candidate parameters you have in mind? Are you referring to the beta-binomial version or the standard version? Etc. – gung - Reinstate Monica Jul 21 '17 at 15:01
• @gung Thanks for your answer. Please see my updated question with some context. Would your suggestion be appropriate for this type of application? – John Jack Jul 21 '17 at 15:32