# Deconvolution in Python

I'm trying to use and understand SciPy's deconvolve for a project I'm working on. I'm having some trouble understanding how to use it.

What I would like to do is to take two PMFs from discrete gaussian distributions and recover an unknown distribution using deconvolution. My understanding is that if I deconvolve the PMF from ~N(10, 1) and the PMF from ~N(30, 2), I should recover the PMF for the distribution ~N(20, 1). How can I do this in SciPy. It would be great, if I could see an example. Thanks in advance for the help.

The function is based on Matlab's deconv, so reading that page should help understand it.

Here's a docstring I wrote for SciPy's deconvolve, but haven't submitted yet because I'm not sure it's 100% correct: https://github.com/scipy/scipy/pull/430#issuecomment-13675004

The input to deconvolve is signal and divisor, and your output is quotient and remainder, where signal was originally produced by signal = convolve(divisor, quotient) + remainder.

original = [0, 1, 0, 0, 1, 1, 0, 0]
impulse_response = [2, 1]
recorded = scipy.signal.convolve(impulse_response, original)
print recorded
# [0 2 1 0 2 3 1 0 0]
recovered, remainder = scipy.signal.deconvolve(recorded, impulse_response)
print recovered, remainder
# [ 0.  1.  0.  0.  1.  1.  0.  0.] [ 0.  0.  0.  0.  0.  0.  0.  0.  0.]


I don't understand what you're trying to do with PMFs, though, so I can't give a more specific example.