Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 rhyminkevin, Today, 04:58 PM
            4 responses
            52 views
            0 likes
            Last Post dp8282
            by dp8282
             
            Started by iceman2018, Today, 05:07 PM
            0 responses
            5 views
            0 likes
            Last Post iceman2018  
            Started by lightsun47, Today, 03:51 PM
            0 responses
            7 views
            0 likes
            Last Post lightsun47  
            Started by 00nevest, Today, 02:27 PM
            1 response
            14 views
            0 likes
            Last Post 00nevest  
            Started by futtrader, 04-21-2024, 01:50 AM
            4 responses
            50 views
            0 likes
            Last Post futtrader  
            Working...
            X