Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Bug in Kurtosis Contrast Function #252

Closed
armwal opened this issue Jun 16, 2016 · 1 comment
Closed

Bug in Kurtosis Contrast Function #252

armwal opened this issue Jun 16, 2016 · 1 comment

Comments

@armwal
Copy link

armwal commented Jun 16, 2016

Hi,

there seems to be a bug in Accord.Statistics.Analysis.ContrastFunctions.Kurtosis.cs

The Evaluate function reads

public void Evaluate(double[] x, double[] output, double[] derivative)
        {
            for (int j = 0; j < x.Length; j++)
            {
                // Kurtosis contrast function and its derivative, as given
                //  in original Hyvärinen's paper. See main references for the
                //  Independent Component Analysis class for details.

                double v = x[j];

                // g(w*x)
                output[j] = v * v * v;

                // g'(w*x)
                derivative[j] = (1.0 / 3.0) * v * v;
            }
        }

However, the derivative should be:

derivative[j] = 3.0 * v * v;

This can be confirmed for example with the ComputeTest() unit test in Accord.Tests.Statistics.IndependentComponentAnalysisTest: Setting ica.Contrast = new Kurtosis(); before computing the ICA fails the test with the old derivative and succeeds with the new one.

Armin

@cesarsouza
Copy link
Member

cesarsouza commented Aug 21, 2016

You are absolutely correct! Many thanks for catching (and solving) this issue!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants