[SciPy-User] convolution density kernel

Scott Sinclair scott.sinclair.za@gmail....
Tue Jan 17 06:26:08 CST 2012

On 17 January 2012 11:35, Johannes Radinger <JRadinger@gmx.at> wrote:
> I'd like to apply a 'convolution' on a probability density kernel.
> Like in: http://graphics.stanford.edu/courses/cs178/applets/convolution.html
> where f=g (for step 1)
> In my case the function (base and that for the convolution) is:
> def pdf(x,sigma_stat,sigma_mob):
>    return (p * stats.norm.pdf(x, loc=m, scale=sigma_stat) + (1-p) * stats.norm.pdf(x, loc=m, scale=sigma_mob))
> this are actually two superimposed normal distributions. Due to computational
> problems I think it easier to sample finely as I just want to represent the result using matplotlib. Furthermore I'd like to do this convolution computation several times, where the output of the last convolution is the input (f) of the next step (function (g) stays the same original one).
> Is there any easy applicable function in scipy to to this convolution? As I am not that familiar with scipy hopefully someone can help me in this case.

You're probably looking for scipy.signal.convolve and
scipy.signal.fftconvolve. fftconvolve will be faster for larger inputs
because the convolution operation can be represented as a simple
multiplication once the inputs are transformed into the Fourier


More information about the SciPy-User mailing list