Page 1 of 1

StdDeviation overflow?

Posted: Tue Apr 07, 2009 9:08 am
by 13049497
Hello,

if i have a lot of big values and will calculate the standard deviation the function will result in wrong values. I think the function have an overflow, in that case it would be nice if the value is set to double.nan or something so that i can recalculate it or change the source.

Example:

Code: Select all

            Steema.TeeChart.Styles.FastLine ser = new Steema.TeeChart.Styles.FastLine();
            Steema.TeeChart.Styles.FastLine stddev = new Steema.TeeChart.Styles.FastLine();
            Steema.TeeChart.Functions.StdDeviation func = new Steema.TeeChart.Functions.StdDeviation();
            stddev.Function = func;

            Random ran = new Random();            

            // 30,000 work -> stddev = 1,200,000,000
            // 400,000 do not work -> stddev = 14,000,000,000 (overflow?)
            for (int i = 0; i < 400000; i++) 
            {
                ser.Add(ran.Next(-2000000000, 2000000000));
            }

            stddev.DataSource = ser;

            tChart1.Series.Add(ser);
            tChart1.Series.Add(stddev);
Thanks!

Posted: Tue Apr 07, 2009 11:56 am
by 10050769
Hello AIS,

I could reproduce your problem and I have added to the list of Bug Report with number [TF02014067] we will try to fix it for next versions of TeeChart .NET.


Thanks,

Posted: Thu Apr 30, 2009 11:41 am
by Chris
Hello!

The issue here is that the algorithms are not producing a System.Overflow exception but that the size of the input data is pushing the calculations beyond the precision of the System.Double type. I've tried using the System.Decimal type in these calculations, but then the code does produce a System.Overflow exception as the range of decimal is relatively small (and the numbers we are talking about are relatively large).

Given that no exceptions are being thrown in the circumstances of calculations overreaching the precision of System.Double, this means that there is no way for us to detect whether or not the algorithms are returning "correct" values. Our best suggestion is that you implement some simple filters yourself, checking, for example, whether or not the standard deviation value returned is outside of the range of the original values. If you have any suggestions as to better solutions, please let us know!

Posted: Mon May 04, 2009 6:01 am
by 13049497
Hello Christopher,

i noticed that DataTable.Compute have the same result like TChart and so i write my own code for this problem if the calculated value is realy incorrect. Now it works and it is not too slow.

Thanks anyway!