• 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

  • cbadr
    started a topic Standard Deviations with different Average

    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.

  • koganam
    replied
    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.

    Leave a comment:


  • cbadr
    replied
    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?

    Leave a comment:


  • koganam
    replied
    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?

    Leave a comment:


  • cbadr
    replied
    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)));
                }
            }

    Leave a comment:


  • koganam
    replied
    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.

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by afoschini, Today, 02:57 AM
0 responses
1 view
0 likes
Last Post afoschini  
Started by jecoyeko, Today, 12:45 AM
0 responses
6 views
0 likes
Last Post jecoyeko  
Started by Newtrader101, Yesterday, 06:31 PM
1 response
9 views
0 likes
Last Post NinjaTrader_EricB  
Started by Tyler7498, Yesterday, 07:34 PM
0 responses
4 views
0 likes
Last Post Tyler7498  
Started by Woomera, Yesterday, 07:24 PM
2 responses
10 views
0 likes
Last Post Woomera
by Woomera
 
Working...
X