@Lusiphur: The LinearGradientBrush is used to fill a shape using linear shading. It does not draw a curved line. This will not help.
I don't think there is anything native to .Net that supports drawing bell curves.
May be someone else can help.
nick.crane
Nearly a Posting Virtuoso
1,230 posts since Feb 2010
Reputation Points: 375
Solved Threads: 188
Skill Endorsements: 3
It is really hot overhere(34°C) but I still managed to do a bit of programming. Having no swimming pool around, what else can a man do? ;)
So here it is, hope it helps.
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double[] D = { 5, 2, 7, 8, 11, 12, 3, 1, 2, 10 };
double[] B = { 4, 8 };
double[] F = FREQUENCY(D, B);
for (int i = 0; i < F.Length; i++)
{
Console.WriteLine(F[i]);
}
Console.WriteLine(NORMDIST(1,42,1.5,false));
Console.ReadKey();
}
// QAD, so little error checking
public static double[] FREQUENCY(double[] Data, double[] Bins)
{
double[] FreqList = new double[Bins.Length + 1];
for (int i = 0; i < FreqList.Length; i++)
{
FreqList[i] = 0.0; //init our list
}
for (int i = 0; i < Data.Length; i++)
{
for (int j = 0; j < Bins.Length; j++)
{
if (Data[i] <= Bins[j])
{
FreqList[j]++;
break; // we don't want to fill others
}
}
if (Data[i] > Bins[Bins.Length - 1])
{
FreqList[Bins.Length]++;
}
}
return FreqList;
}
//evaluation of the bell curve. See http://en.wikipedia.org/wiki/Normal_distribution
public static double NORMDIST(double x, double mean, double standard_dev, bool cumulative)
{
double fact = standard_dev * Math.Sqrt(2.0 * Math.PI);
double expo = (x - mean) * (x - mean) / (2.0 * standard_dev * standard_dev);
//if (cumulative) do integration from 0 to x
//look at this snippet for A way not THE way to do this:
//http://www.daniweb.com/code/snippet217197.html
//else just return the value:
return Math.Exp(-expo) / fact;
}
}
}
ddanbe
Industrious Poster
4,307 posts since Oct 2008
Reputation Points: 2,126
Solved Threads: 725
Skill Endorsements: 26
Question Answered as of 2 Years Ago by
Lusiphur,
ddanbe
and
nick.crane