Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Microsoft .Net & .Net Compact Framework
 QCChart2D and QCChart2D CF (VB and C#)
 Normal distribution (Gaussian) graph
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

leontiosp

6 Posts

Posted - 04 Jun 2009 :  02:07:53  Show Profile  Reply with Quote
Hi,

how can I create a graph of the standard normal distribution curve?

quinncurtis

1164 Posts

Posted - 04 Jun 2009 :  09:11:35  Show Profile  Reply with Quote
Our Charting software plots the data you give it. It is up to you to define the data points you intend to plot.

For a normal curve, you would create x and y vectors containing data points sampled along the normal curve for your range of X-values, fixed mean, and fixed standard deviation. Then create a SimpleDataset and plot the points using a SimpleLinePlot.

The normal distribution is defined by the following equation:
Normal equation. The value of the random variable Y is:

Y = [ 1/Sigma * sqrt(2*PI) ] * e-(x - Mean)^2/2*Sigma^2

See http://stattrek.com/Lesson2/Normal.aspx

where X is a normal random variable,Mean is the mean,Sigma is the standard deviation, PI is approximately 3.14159, and e is approximately 2.71828.

Something similar to the code below will plot a normal distribution (sampled at 100 points) 5 standard deviations to the left and right of the given mean.

double[] normalx = new double[100];
double[] normaly = new double[100];

double normv = 0;
double xval = 0;
double mean = 10;
double stddev = 1;


for ( i = 0; i < normalx.Length; i++)
{
   xval = mean - 5 * stddev + i * (5 * stddev) / 50;
   normv = Math.Exp(-0.5 * Math.Pow((xval - mean) / stddev, 2)) * (1.0 / (stddev * Math.Sqrt(2.0 * Math.PI)));
   normalx[i] = xval;
   normaly[i] = normv;
}

SimpleDataset normDataset;
normDataset = new SimpleDataset("NormDataset", normalx, normaly);
SimpleLinePlot normPlot = new SimpleLinePlot(pTransform1, normDataset, attrib1);
chartVu.AddChartObject(normPlot);

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-07 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07