mohamadDev / aforge

Automatically exported from code.google.com/p/aforge
Other
0 stars 0 forks source link

Histogram Min and Max not calculated correctly. #87

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In Histogram.cs, Update() does not calculate Min and Max correctly. I 
believe the following is a better implementation (however this routine 
will NOT return the index of the minimum non-zero value:

public void Update( )
{
    int i;

    max = 0;
    min = 0;

    // calculate min and max
    for ( i = 0; i < values.Length; i++ )
    {
        if ( values[i] != 0 )
        {
            // max
            if ( values[i] > values[max] )
                max = i;
            // min
            if ( values[i] < values[min] )
                min = i;
        }
    }

    mean = Statistics.Mean( values );
    stdDev = Statistics.StdDev( values );
    median = Statistics.Median( values );
}

Original issue reported on code.google.com by joetut...@gmail.com on 19 Jan 2009 at 8:34

GoogleCodeExporter commented 9 years ago
Min and Max are calculated correctly. Check docs:

/// <summary>
/// Minimum value.
/// </summary>
/// 
/// <remarks><para>The property allows to retrieve minimum value of the 
histogram 
with non zero
/// hits count.</para>

May clarify ore, if docs are not clear enough. But the idea is that is was done 
intentionally and was supposed to be so.

Original comment by andrew.k...@gmail.com on 24 Jan 2009 at 8:37