Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Statistical Functions in C#

Statistical Functions in C#

Scheduled Pinned Locked Moved C#
helpcsharp
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AZBugsBunny
    wrote on last edited by
    #1

    I would like to know if there is any built in function/library in C# which lets me solve the foll. Statistical problem: Given the mean and the variance of a normal distribution, I want to get the sample points that are arrived at based on the mean and variance. (Basically some function similar to the Worksheet function NormInv in MSExcel). Right now I am doing a very kludgy solution where I create an Excel Worksheet function object just to access the function. This makes my application real slow. :( Moreover I need this type of evaluation to be done possibly 10,000 times as I am developing some kind of a simulator. Anybody please help !!!!

    L K D 4 Replies Last reply
    0
    • A AZBugsBunny

      I would like to know if there is any built in function/library in C# which lets me solve the foll. Statistical problem: Given the mean and the variance of a normal distribution, I want to get the sample points that are arrived at based on the mean and variance. (Basically some function similar to the Worksheet function NormInv in MSExcel). Right now I am doing a very kludgy solution where I create an Excel Worksheet function object just to access the function. This makes my application real slow. :( Moreover I need this type of evaluation to be done possibly 10,000 times as I am developing some kind of a simulator. Anybody please help !!!!

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      Those methods wouldnt be hard at all to implement in a class or two. In fact thats a good idea for your 1st article here at CodeProject. :) leppie::AllocCPArticle("Zee blog");
      Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.

      1 Reply Last reply
      0
      • A AZBugsBunny

        I would like to know if there is any built in function/library in C# which lets me solve the foll. Statistical problem: Given the mean and the variance of a normal distribution, I want to get the sample points that are arrived at based on the mean and variance. (Basically some function similar to the Worksheet function NormInv in MSExcel). Right now I am doing a very kludgy solution where I create an Excel Worksheet function object just to access the function. This makes my application real slow. :( Moreover I need this type of evaluation to be done possibly 10,000 times as I am developing some kind of a simulator. Anybody please help !!!!

        K Offline
        K Offline
        Kevin McFarlane
        wrote on last edited by
        #3

        I'm sure I remember there being a C# math library on the web somewhere - probably not free though and I can't remember what it was called or whether it supported stats. Ah, just did a search and there's one here: http://www.centerspace.net/products.php?page=3[^] The stats library is released next month. Kevin

        1 Reply Last reply
        0
        • A AZBugsBunny

          I would like to know if there is any built in function/library in C# which lets me solve the foll. Statistical problem: Given the mean and the variance of a normal distribution, I want to get the sample points that are arrived at based on the mean and variance. (Basically some function similar to the Worksheet function NormInv in MSExcel). Right now I am doing a very kludgy solution where I create an Excel Worksheet function object just to access the function. This makes my application real slow. :( Moreover I need this type of evaluation to be done possibly 10,000 times as I am developing some kind of a simulator. Anybody please help !!!!

          L Offline
          L Offline
          leppie
          wrote on last edited by
          #4

          Now that kevin mentioned it. Do a search for Math.NET and Euler.NET on SOurceforge, both provide stats functions i think. leppie::AllocCPArticle("Zee blog");
          Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.

          1 Reply Last reply
          0
          • A AZBugsBunny

            I would like to know if there is any built in function/library in C# which lets me solve the foll. Statistical problem: Given the mean and the variance of a normal distribution, I want to get the sample points that are arrived at based on the mean and variance. (Basically some function similar to the Worksheet function NormInv in MSExcel). Right now I am doing a very kludgy solution where I create an Excel Worksheet function object just to access the function. This makes my application real slow. :( Moreover I need this type of evaluation to be done possibly 10,000 times as I am developing some kind of a simulator. Anybody please help !!!!

            D Offline
            D Offline
            Donald_a
            wrote on last edited by
            #5

            I'm not sure exactly what you are after, but this may help? using System; namespace NormInvFunc{ public class Normal { private static double Density(double x) { double y=Math.Pow (2*Math.PI ,-.5)*Math.Exp(-.5*x*x); return y; } public static double StandardNormal(double x) { double [] a=new double[5]; a[0]=.31938153; a[1]=-.356563782; a[2]=1.781477937; a[3]=-1.821255978; a[4]=1.330274429; double K=.2316419; double L=Math.Abs(x); double nx=Density(L); double q=1/(1+K*L); double S=0; for(int j=0;j<5;j++) { S+= a[j]*Math.Pow(q,j+1); } double SND=1-nx*S; if(x<0) { SND=1-SND; } return SND; } public static double StandardNormalInv(double R) { double Delta=1; double X=0; double Y=0; do { Y=X-(StandardNormal(X)-R)/Density(X); Delta=Math.Abs (Y-X); X=Y; } while (Delta>.000000001); return Y; } } } NB will not return quite as many decimal places as excel.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups