# Arrays, Mapping, and Convolutions

I'm trying to create a function that convolutes a 3D Normal Distribution to the points listed below. However, I think I'm going about it in the wrong way.

When I try and convolve it with the points, listed as the delta function, it doesn't plot correctly.

I think I could try and rewrite it in terms of mapping the DiracDelta[] (Map[DiracDelta[x-#],array]?)to the points listed, but since its in two dimensions, I'm not sure how to make it work.

mc = {202, 155};
mR1 = {230, 100};
mR2 = {235, 123};
mR3 = {240, 150};
mL1 = {165, 139};
mL2 = {168, 169};
mL3 = {175, 188};
mU = {209, 175};
mD = {196, 112};

ThreeDnd[x_, y_, \[Sigma]1_, \[Sigma]2_] :=
PDF[BinormalDistribution[{0, 0}, {\[Sigma]1, \[Sigma]2}, 1/2], {x,
y}];
Plot3D[ThreeDnd[x, y, 5, 5], {x, -dm/2, dm/2}, {y, -dm2/2, dm2/2},
PlotRange -> All]

mask[x_, y_, \[Sigma]1_, \[Sigma]2_] := Convolve[
(DiracDelta[x - mc[], y - mc[]] +
DiracDelta[x - mR1[], y - mR1[]] +
DiracDelta[x - mR2[], y - mR2[]] +
DiracDelta[x - mR3[], y - mR3[]] +
DiracDelta[x - mL1[], y - mL1[]] +
DiracDelta[x - mL2[], y - mL2[]] +
DiracDelta[x - mL3[], y - mL3[]] +
DiracDelta[x - mU[], y - mU[]] +
DiracDelta[x - mD[], y - mD[]]),
ThreeDnd[x, y, \[Sigma]1, \[Sigma]2],
x, y,
z]
mask[x, y, \[Sigma]1, \[Sigma]2]

Plot3D[mask[x, y, 5, 5], {x, -dm, dm}, {y, -dm2, dm2},
PlotRange -> All]


The output should be a 3D distribution centered at each of the points.

I'll take this mask then multiply it with a Fourier transform.

Please help. I'm really stuck.

Edit: I thought I'd try mapping the points to the delta distributions, but that doesn't seem to work either

Test2 = Map[(-# + {x, y}) &, {mc, mR1, mR2, mR3, mL1, mL2, mL3, mU,
mD}]
Test3 = Total[DiracDelta /@ Test2]
mask[x_, y_, \[Sigma]1_, \[Sigma]2_] := Convolve[
Test3,
ThreeDnd[x, y, \[Sigma]1, \[Sigma]2],
x, y]
mask[x, y, \[Sigma]1, \[Sigma]2]

• Could you use KernelMixtureDistribution instead? – Chris K May 5 '19 at 22:00
• I don't know what that is? How it would work? – Lil Coder May 5 '19 at 22:01
• Could you explain a bit more about what you want the output to be? – Chris K May 5 '19 at 22:10
• I want to essentially "map" the ThreeDnd function to the position of each of the points I've listed in my code. I thought I could achieve this by convoluting a delta distribution with those points with ThreeDnd If you check out my earlier post, you can see an image of what ThreeDnd plots. I'd like one of those centered at each one of the points. mathematica.stackexchange.com/questions/197755/… – Lil Coder May 5 '19 at 22:21

## 1 Answer

Something like this?

pts = {mc, mR1, mR2, mR3, mL1, mL2, mL3, mU, mD};
ThreeDnd[x_, y_, pt_, σ1_, σ2_] :=
PDF[BinormalDistribution[pt, {σ1, σ2}, 1/2], {x, y}];
Plot3D[
Evaluate[Sum[ThreeDnd[x, y, pt, 5, 5], {pt, pts}]]
, {x, 100, 300}, {y, 100, 200}
, PlotRange -> All, PlotPoints -> 100] 