Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Guassian Function

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

    Guassian Function

    Was trying to add a function for calculating the guassian value and it doesn't seem to be working. Anyone know what the bug is or a better way to do it?

    double m = 0;
    double s = 1;
    double v = 1;
    Print(
    string.Format("Guassian({0},{1},{2}): {3:0.00}",m,s,v,GetNormalGuassian(m,s,v)));

    public double GetNormalGuassian(double mean, double stdev, double x)
    {
    double a = 1 / (stdev * Math.Sqrt(2 * Math.PI));
    double num = Math.Pow(x-mean,2);
    double den = 2 * Math.Pow(stdev,2);
    return a * Math.Exp(-num/den);
    }

    comes up with 0.24, should be 0.84 according to excel
    Last edited by darckeen; 07-25-2009, 01:07 AM.

    #2
    Hello,

    I am sorry, I am not familiar with this indicator calc. Try printing each value out just prior to it being used in your calculation, then post those results and I'll see if I can help.
    DenNinjaTrader Customer Service

    Comment


      #3
      The calc is more commonly known as the probability density function. It turns out the code was fine. My problem was that I was using the wrong function, instead I wanted the cummulative density function. Thanks for the help.

      Comment


        #4
        If you are looking to get accurate density approximation you should check out support vector machines, there is a .net port of libsvm. The 'one-class' svc technique yields a good estimate of sample density. =)

        Another popular method for density approximation is to use sequential monte carlo techniques but I don't think there are any open source implementations for .net

        Comment


          #5
          I found a good algorithm for it here http://www.sitmo.com/doc/Calculating...l_Distribution, but i'll check out that library cause i also would like to find something for the student t distribution.

          Comment


            #6
            Originally posted by darckeen View Post
            I found a good algorithm for it here http://www.sitmo.com/doc/Calculating...l_Distribution, but i'll check out that library cause i also would like to find something for the student t distribution.
            here is a port of quantlib http://quantlib.org/index.shtml from c++ to c#. i have not look at this.



            and on sourceforge

            Download QLNet for free. *** MOVED TO GITHUB : https://github.com/amaggiulli/qlnet *** QLNet is a financial library written in c# for the Windows enviroment derived primarily from its C++ counterpart, Quantlib, which has been used as a base reference for modelling of various financial instruments.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            599 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            344 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            558 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            557 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X