StdDeviation with Offset?

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

StdDeviation with Offset?

Post by AIS » Fri Mar 27, 2009 2:01 pm

Hello,

i use a fastline (f1) with a custom axis and a second fastline (f2) with datasource = f1. The second one has also the function stddeviation set. In that case, the line f2 has also the same axis like f1 and is automaticly shown at the bottom of the chart. now i want to show f2 relative to the average of f1. For example now:

|
|---------------------- f1
|
|
|
|
|----------------------- f2 (stddev)
|________________

wanted:

|----------------------- f2 (stddev)
|---------------------- f1
|----------------------- f2 (stddev)
|
|
|
|
|________________

The value of f2 is correct, but must be shown relatively to the average of f1 so you can see the relationship of f1 and f2. How can i achieve this without to calculate the stdev for my own :)?

Thanks in advance!

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Mar 27, 2009 3:46 pm

Hi AIS,

I'm not sure about what you are trying to achieve but you can calculate Average and Std. Deviation for datasource series, for example:

Code: Select all

		public Form1()
		{
			InitializeComponent();
			InitializeChart();
		}

		private void InitializeChart()
		{
			Steema.TeeChart.Styles.FastLine fastLine1 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
			fastLine1.Title = "Data";
			fastLine1.FillSampleValues();

			Steema.TeeChart.Styles.FastLine avgLine = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
			avgLine.Title = "Average";
			Steema.TeeChart.Functions.Average average1 = new Steema.TeeChart.Functions.Average();
			avgLine.Function = average1;
			avgLine.DataSource = fastLine1;

			Steema.TeeChart.Styles.FastLine stdDevLine = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
			stdDevLine.Title = "Std. Deviation";
			Steema.TeeChart.Functions.StdDeviation stdDev1 = new Steema.TeeChart.Functions.StdDeviation();
			stdDevLine.Function = stdDev1;
			stdDevLine.DataSource = fastLine1;
		}
If that's not what you need please provide more information. An image might be helpful. You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

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

Post by AIS » Mon Mar 30, 2009 6:21 am

Hi Narcís,

for better understanding what i want to do:
Image


Image

You can see, that the std. deviation in the second picture is not at the bottom of the chart like in the first one. The two lines are avg-std.dev and avg+std.dev. Is it possible to combine the functions or set an offset for std.dev. to achieve this?

Thanks!

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Mar 30, 2009 5:23 pm

Hi AIS,

In that case you can do this:

Code: Select all

    public Form1()
    {
      InitializeComponent();
      InitializeChart();
    }

    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;

      Steema.TeeChart.Styles.FastLine fastLine1 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
      fastLine1.Title = "Data";
      fastLine1.FillSampleValues();

      Steema.TeeChart.Styles.FastLine avgLine = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
      avgLine.Title = "Average";
      Steema.TeeChart.Functions.Average average1 = new Steema.TeeChart.Functions.Average();
      avgLine.Function = average1;
      avgLine.DataSource = fastLine1;

      Steema.TeeChart.Styles.FastLine stdDevLine = new Steema.TeeChart.Styles.FastLine();
      stdDevLine.Title = "Std. Deviation";
      Steema.TeeChart.Functions.StdDeviation stdDev1 = new Steema.TeeChart.Functions.StdDeviation();
      stdDevLine.Function = stdDev1;
      stdDevLine.DataSource = fastLine1;

      Steema.TeeChart.Styles.FastLine avgPlusStdDev = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
      Steema.TeeChart.Styles.FastLine avgLessStdDev = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);

      for (int i = 0; i < avgLine.Count; i++)
      {
        avgPlusStdDev.Add(avgLine.XValues[i], avgLine.YValues[i] + stdDevLine.YValues[i]);
        avgLessStdDev.Add(avgLine.XValues[i], avgLine.YValues[i] - stdDevLine.YValues[i]);
      }
    }
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

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

Post by AIS » Tue Mar 31, 2009 8:09 am

Hi Narcís,

yes, this is a solution but with a bad performance. In our case we often have 5-10 series each with over 80000 points (x,y) and an own average and st.dev. This solution costs a lot of performance when the avg period is small (e.g. 1), because we must loop all average points. Nevertheless i will use it ;)

Thanks anyway for your quick response!

Bye!

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Mar 31, 2009 8:34 am

Hi AIS,

You could try applying hints in the Real-time Charting article here:

http://www.teechart.net/reference/articles/index.php
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

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

Post by AIS » Tue Mar 31, 2009 11:02 am

Hi Narcís,

this article is already implemented :)
BTW: Our customer would like to see points instead of fastlines therefore not all optimizations are possible.. :(

Post Reply