• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Standard Deviations with different Average

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Standard Deviations with different Average

    Hello,


    I have developed custom Standard Deviation based on different average like the:

    1. Geometrical average

    2. Harmonic average

    3. Quadratic average


    As shown in the attached pic, i would like to understand why, for the same Period:

    1. The Regular Stdev is almost equal to the Harmonic StdDev
    2. The Geom Stdev is almost equal to the Quadratic StdDev


    It's more like a maths problem but i would be interested to have a feedback...


    Thanks
    Attached Files
    Last edited by cbadr; 06-12-2018, 01:12 AM.

    #2
    Originally posted by cbadr View Post
    Hello,


    I have developed custom Standard Deviation based on different average like the:

    1. Geometrical average

    2. Harmonic average

    3. Quadratic average


    As shown in the attached pic, i would like to understand why, for the same Period:

    1. The Regular Stdev is almost equal to the Harmonic StdDev
    2. The Geom Stdev is almost equal to the Quadratic StdDev


    It's more like a maths problem but i would be interested to have a feedback...


    Thanks
    That would be impossible to tell with certainty without seeing the code. Offhand, it would most likely be because your code refactors to identical code between the matching methods.

    Comment


      #3
      Thanks for the answer.
      Here the code i used for the Geometrical Average:
      But after investigations on google, i realized i couldn't used the same Std calculation once the Mean is calculated.
      I'll have to update the formula accordingly.
      Any thoughts on this?



      Code:
      protected override void OnBarUpdate()
              {
                  if (CurrentBar < 1)
                  {
                      Value.Set(0);
                      sumSeries.Set(Input[0]);
                  }
                  else
                  {
                      sumSeries.Set(Input[0] * sumSeries[1] * (CurrentBar >= Period ? 1/Input[Period]: 1));
                      double avg = Math.Pow(sumSeries[0],1/Math.Min(CurrentBar + 1, Period));
                      double sum = 0;
                      for (int barsBack = Math.Min(CurrentBar, Period - 1); barsBack >= 0; barsBack--)
                          sum += (Input[barsBack] - avg) * (Input[barsBack] - avg);
      
                      Value.Set(Math.Sqrt(sum / Math.Min(CurrentBar + 1, Period)));
                  }
              }

      Comment


        #4
        Originally posted by cbadr View Post
        Thanks for the answer.
        Here the code i used for the Geometrical Average:
        But after investigations on google, i realized i couldn't used the same Std calculation once the Mean is calculated.
        I'll have to update the formula accordingly.
        Any thoughts on this?



        Code:
        protected override void OnBarUpdate()
                {
                    if (CurrentBar < 1)
                    {
                        Value.Set(0);
                        sumSeries.Set(Input[0]);
                    }
                    else
                    {
                        sumSeries.Set(Input[0] * sumSeries[1] * (CurrentBar >= Period ? 1/Input[Period]: 1));
                        double avg = Math.Pow(sumSeries[0],1/Math.Min(CurrentBar + 1, Period));
                        double sum = 0;
                        for (int barsBack = Math.Min(CurrentBar, Period - 1); barsBack >= 0; barsBack--)
                            sum += (Input[barsBack] - avg) * (Input[barsBack] - avg);
        
                        Value.Set(Math.Sqrt(sum / Math.Min(CurrentBar + 1, Period)));
                    }
                }
        Whereas you are using a rather inefficient algorithm, I nonetheless do not quite understand what you are asking. You appear to be calculating a mean, then looping backwards and summing the squares of the deviations from the mean. That is the basic definition of how to determine the variance and hence StdDev. So what is the issue?

        Comment


          #5
          The issue is about understanding the result of the StdDev from a Geometric VS Harmonic VS Squared Mean.


          From wikipedia i found that the formula to get the Geometric Std is mention there:


          https://en.wikipedia.org/wiki/Geomet...dard_deviation


          Thats a first thing i have to update on the script.


          Then really i am wondering if the Std formala is the same for the other Mean?

          Comment


            #6
            Originally posted by cbadr View Post
            The issue is about understanding the result of the StdDev from a Geometric VS Harmonic VS Squared Mean.


            From wikipedia i found that the formula to get the Geometric Std is mention there:


            https://en.wikipedia.org/wiki/Geomet...dard_deviation


            Thats a first thing i have to update on the script.


            Then really i am wondering if the Std formala is the same for the other Mean?
            For an unbiased estimator, the standard deviation is always the Root Mean Square Deviation, the square root of the variance, regardless of what mean you are using, albeit the mean used is almost always the arithmetic mean, rather than any other.

            Why do you think that a geometric mean may be more appropriate for what you are trying to do, if I may ask.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by E-Viper87, Today, 02:50 PM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_PatrickG  
            Started by diddyp1990, Today, 01:28 PM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_Paul  
            Started by dariuszszyc, Today, 09:08 AM
            8 responses
            32 views
            0 likes
            Last Post Nicolas
            by Nicolas
             
            Started by pman777, Today, 12:08 PM
            2 responses
            6 views
            0 likes
            Last Post pman777
            by pman777
             
            Started by Sadat, Today, 09:09 AM
            5 responses
            22 views
            0 likes
            Last Post NinjaTrader_JoshG  
            Working...
            X