Search code examples
packagejuliadelta

Is there a discrete dirac delta function in Julia?


The title sums it up. I have seen some mentions in the RatFun and SpectralMeasures package but I am mostly looking for a function analogous to the ones found in the Sympy module for Python.

Edit: Thanks everyone for your answers and comments. I was looking for the discrete version of a dirac delta. At first I was confused and wanted to look for a "function" but I actually was just looking for the Kronecker delta which exhibits the following behavior:

delta(x) = 1 if x=0

delta(x) = 0 otherwise

I quickly realized that I didn't even need a function, I just had to take care of the differences in the argument. Thanks again!


Solution

  • The OP basically wants the Kronecker delta function [https://en.wikipedia.org/wiki/Kronecker_delta] which is trivial in julia:

    delta(n) = n == 0