﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
316	clipped statistics broken, multiple bugs	Paul Price	gusciora@…	"There are several bugs in the clipped statistics function that eliminate its
functionality.  There exist no workarounds to these.

1. The function does not iterate the specified number of times: once a single
iteration is completed, the function gets sample statistics (mean, standard
deviation), and then if these are not NAN, immediately jumps out of the
iteration loop:

        if (! (isnan(stats->sampleMean) || isnan(stats->sampleStdev))) {
            clippedMean = stats->sampleMean;
            clippedStdev = stats->sampleStdev;
            // Exit loop
            i = stats->clipIter;
        }

2. Values in the vector which are to be clipped are actually not clipped (in
addition to the above problem 1), due to transposing ""i"" for ""j"" in the mask:

            for (j = 0; j < myVector->n; j++) {
                if (fabs(myVector->data.F32[j] - clippedMean) >
(stats->clipSigma * errors->data.F32[j])) {
                    tmpMask->data.U8[i] = 0xff;
                }
            }

3. The function calculating the clipped mean uses the same psStats object to
calculate the sample statistics during the iterations, potentially overwriting
some data that the user wants to keep.

4. The clipped statistics function is actually run twice, since it appears in
two ""if"" statements, both of which are executed if the function does not return -1:

    if ((stats->options & PS_STAT_CLIPPED_MEAN) || (stats->options &
PS_STAT_CLIPPED_STDEV)) {
        if (-1 >  p_psVectorClippedStats(inF32, errorsF32, mask, maskVal, stats)) {
            ...
        } else if (-2 == p_psVectorClippedStats(inF32, errorsF32, mask, maskVal,
stats)) {
            ...
        }
    }"	defect	closed	highest		types	0.4.0	critical	fixed		
