3
$\begingroup$

Let's say I have a function that represents how much light is produced within a particular volume:

gamma[t_] := Piecewise[{{0.2 Exp[-t/13] + 0.5 Exp[-t/35] + 0.3 Exp[-t/270],  t >= 0}}, 0]

And let's say that the light is collected at one end of this volume, and the arrival time is gaussian distributed for a particular source time (i.e. if we isolate all of the light emitted at t, then it will arrive in a gaussian distribution centered around t' with a particular standard deviation).

Thus far I have come up with this:

gaussian[t_, μ_, σ_] := 1/(σ Sqrt[2 Pi]) Exp[-(1/2) ((t - μ)/σ)^2]

SetAttributes[gaussianSmear, HoldAll]

gaussianSmear[t_, f_[a___, y_, b___], σ_] := NIntegrate[ 
  f[a, y, b] gaussian[t, y, σ], {y, t-6σ, t+6σ}]

This will work, but it is very slow. Is there a faster way to perform this? Or is there a built-in function of some kind? I'm aware of the function GaussianFilter, but it only seems to operate on discrete data, not an arbitrary function.

An example usage, original function:

gamma[t_] := Piecewise[{{0.2 Exp[-t/13] + 0.5 Exp[-t/35] + 0.3 Exp[-t/270],  t >= 0}}, 0]
neutron[t_] := Piecewise[{{0.2 Exp[-t/13] + 0.5 Exp[-t/59] + 0.3 Exp[-t/490], t >= 0}}, 0]
Plot[{gamma[t], neutron[t]}, {t, 0, 80}, 
 PlotLegends -> {"gamma", "neutron"}, PlotRange -> {0, 1}, 
 PlotLabel -> "Theoretical activity of crystal", 
 AxesLabel -> {"Time (ns)", "Output level"}]

enter image description here

An example usage, after smearing:

Plot[{gaussianSmear[t, gamma[y], 1], 
  gaussianSmear[t, neutron[y], 1]}, {t, -2, 80}, PlotRange -> {0, 1}, 
 PlotLegends -> {"gamma", "neutron"}, 
 PlotLabel -> "Light collected by SiPM", 
 AxesLabel -> {"Time (ns)", "Output level"}]

enter image description here

$\endgroup$
4
  • $\begingroup$ x is not defined. An example of how to use gaussianSmear would be nice also. $\endgroup$
    – C. E.
    Aug 26, 2018 at 18:14
  • $\begingroup$ Sorry, I changed variables from x to t when translating this from my notebook in order to make my intentions more clear, and I missed an instance. $\endgroup$ Aug 26, 2018 at 18:15
  • $\begingroup$ Examples added. $\endgroup$ Aug 26, 2018 at 18:20
  • $\begingroup$ @OmnipotentEntity Thank you for the update. $\endgroup$
    – C. E.
    Aug 26, 2018 at 18:20

1 Answer 1

5
$\begingroup$

Well, this is a bit embarrassing.

I just realized that what I was performing was essentially a convolution of my original wave form with a standard Gaussian with a mean of 0.

So in other words, I can simply write:

Convolve[gamma[t], gaussian[t, 0, 1], t, y]

To get a function that can be directly plotted and manipulated much faster than my NIntegrate monstrosity.

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.