help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why aren't these convolution results equal to each other?


From: Max Görner
Subject: Why aren't these convolution results equal to each other?
Date: Tue, 19 Apr 2016 10:39:42 +0200
User-agent: KMail/5.0.2 (Linux/4.2.0-35-generic; KDE/5.15.0; x86_64; ; )

Dear list,

I struggle with some deviations of results derived on different ways.
I would like to discuss these with you. I'm using Octave 4.0.0 on Ubuntu
15.10.

The first problem concerns different ways to do 1D convolution. Please
see the following listing:

    kernel = normpdf (1:100, 50, 10);
    M = randn(1, 199);
    m1 = convn(M, kernel, 'valid');
    m2 = conv(M, kernel, 'valid');
    m3 = conv2(1, kernel, M, 'valid');
    disp([isequal(m1, m2), isequal(m1, m3), isequal(m2, m3)]);

Here m1 == m3 (i.e. convn == conv2), but m1 != m2 and m2 != m3. On
Matlab R2015b it's only m1 == m2. I suspected that m1 == m2 == m3.

The second problem concerns different ways to do 2D convolution. Please
see the following listing:

    kernel = normpdf(1:100, 50.5, 10);
    M = randn(199);
    m1 = conv2(abs(kernel), 1, conv2(1, kernel, M, 'valid'), 'valid');
    m2 = conv2(1, kernel, conv2(abs(kernel), 1, M, 'valid'), 'valid');
    m3 = conv2(abs(kernel), kernel, M, 'valid');
    disp([isequal(m1, m2), isequal(m1, m3), isequal(m2, m3)]);

Here m1 != m2 and m1 != m3 and m2 != m3. On Matlab R2015b it is m2 ==
m3. I suspected, that exactly one of m1 or m2 equals m3, since either
the vertical or the horizontal convolution should take place first.

So now I'm a bit irritated, since I suspected bit equality in some of
the results above but got small deviations. I hesitate to blame floating
point arithmetics for thoose deviations.

Could someone explain why these results are different and why this has
to be that way or why it is acceptable?

sincerely,
Max Görner

-- 
PGP: https://wwwpub.zih.tu-dresden.de/~maxgoern/2FE6023F.asc

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]