# Demystify Dirac delta function for data representation on discrete space

[This article was first published on

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Dirac delta function is an important tool in Fourier Analysis. It is used specially in electrodynamics and signal processing routinely. A function over set of data points **Scientific Memo**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

is often shown with a delta function representation. A novice reader relying on integral properties of the delta function may found this notation quite confusing. Probably, the notation itself is an example of abuse of notation.

**One dimensional function/distribution: Sum of delta functions**

Let’s define a one dimensional function, $f(x)$ as follows, $x \in \mathbb{R}$ and $a$ being constant:

$ f(x) = a \sum_{i=-n}^{n} \delta(x – x_{i})$

This representation is inspired from Dirac comb and used in spike trains. Note that set of data points in one dimension $\{x_{i} \}$ will determine the graph of this function. Using the shifting property of delta function, the value of the function will be zero every where except on data points. The constant $a$ will simply be the height of the graph at the data point.

Figure: A spike train. |

**Numeric Example**

Let’s plot $f(x)$ for some specific values of the set $\{x_{i} \} = {-0.5, -0.2, -0.1, 0.2, 0.4}$ and $a=0.5$. Here is the R code for plotting this spike train.

x_i = c(-0.5, -0.2, -0.1, 0.2, 0.4) a = c(0.5, 0.5, 0.5, 0.5, 0.5) plot(x_i,a,type="h",xlim=c(-0.6,0.6),ylim=c(0,0.6),lwd=2,col="blue",ylab="p")

**Representing Histograms: One dimensional example**

Particularly convenient representation of histograms can be developed similarly. Consider set of points $\{x_{i}\}_{i=1}^{n}$ where we would like to establish a histogram out of this set, let’s say $h(x)$. If we set our histogram intervals as $\{x_{j}\}_{j=1}^{m}$. The histogram $h(x)$ then can be written as

$h(x_{j}) = \sum_{i=1}^{n} \sum_{j=1}^{m} \delta(x_{j}- x_{i}^{min})$

where set $x_{i}^{min}$ represents the the the value from set $\{x_{j}\}_{j=1}^{m}$ that is closest to given $x_{i}$. Where as, second sum determines the height at a given point, i.e., frequency. This is just a confusing mathematical representation and practical implementation only counts the frequency of $x_{i}^{min}$ directly.

**Conclusion**

However it is quite trivial, the above usage of sum of delta functions appear in mathematical physics as well, not limited to statistics.

To

**leave a comment**for the author, please follow the link and comment on their blog:**Scientific Memo**.R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.