I have a function that produce an array with values that are Gaussian(normal) distribute. If you plot the values on a graph, it would look something like this:
Is there any way to improve on the code?
private static IComparable[] NonUniformDistributionsGaussian(int startNumber,int arraySize)
{
IComparable [] arr = new IComparable[arraySize];
for (var i = 0; i < arraySize; i++)
{
if (i <= (int)((1.00 / 3.00) * arraySize))
{
startNumber = startNumber + 1;
arr[i] =startNumber;
}
if (i >= (int)((1.00 / 3.00) * arraySize) && i <= ((2.00 / 3.00) * (double)arraySize))
{
startNumber = startNumber + 2;
arr[i] = startNumber;
}
if ( i > ((2.00 / 3.00) * arraySize))
{
startNumber = startNumber - 2;
arr[i] = startNumber;
}
}
return arr;
}