StdDeviation overflow?

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Posts: 70
Joined: Wed Jun 25, 2008 12:00 am

StdDeviation overflow?

Post by AIS » Tue Apr 07, 2009 9:08 am


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.


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;


Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Post by Sandra » Tue Apr 07, 2009 11:56 am

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.

Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
Image Image Image Image Image Image
Instructions - How to post in this forum

Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia

Post by Christopher » Thu Apr 30, 2009 11:41 am


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!
Thank you!

Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:

Posts: 70
Joined: Wed Jun 25, 2008 12:00 am

Post by AIS » Mon May 04, 2009 6:01 am

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!

Post Reply