2

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!

Madlad
  • 125
  • 12
  • 3
    I am not at all sure that the title sums it up at all. Dirac delta isn't a function in the mathematical sense. It's integral is. And It acts like the pdf of a distribution in some circumstances. I think you need to tell us what circumstances you have and what your actual use cases are. – Frames Catherine White Jan 20 '21 at 22:37
  • @LyndonWhite Apologies. I wanted to use the Dirac delta distribution in an unconventional sense. I'm not really looking to integrate it. What I did at the end, was to do a function where if the (sum of) values inputted are 0, the function will give me 1 and otherwise 0. – Madlad Jan 21 '21 at 17:32
  • 1
    If you search https://juliahub.com for `onehot` you'll find several packages that support a vector with a single nonzero element. – tholy Jan 21 '21 at 20:49
  • 1
    @LyndonWhite the Dirac delta is most certainly valid mathematically, as the limit of a sequence of functions whose width goes to zero as the peak goes to Inf. However it appears that the OP is looking for the discrete analogous function, not the continuous function. – Carl Witthoft Jan 22 '21 at 19:14
  • 1
    Although there is an accepted answer, it would be nice to edit the question and have it explicitly say what is the behavior you are looking for, maybe with some example. So then when someone looks for something similar and stumbles upon this question, they can know if it will be useful for them without having to go out to Sympy docs. – aramirezreyes Feb 03 '21 at 22:05

2 Answers2

2

There is a Dirac type in MeasureTheory.jl, but unsure if it fits your needs.

Benoit Pasquier
  • 2,868
  • 9
  • 21
0

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

delta(n) = n == 0