Gavin
Gavin

Reputation: 2173

c# draw a bell curve from a mean and a standard deviation

Is there a way to generate a Bell curve from a standard deviation and a mean? I have read reference to this but cant find an algorthym.

I have a list of numbers, they are pre-normalised look ups (score=>percentile). Which I have ranged and I need to draw a bell curve from so that I can colour sections of area under the curve to represent scores on charts (an area chart I suppose / infrographic esk). I am stuck at the first hurdle really.

I planned to draw a historgram by ranging the data in the following way:

int count = data.Count-1;  

        for (int i = 0; i < count; i++ )
        {
            data[i] = data[i + 1] - data[i]; //range
        }

        data[data.Count - 1] = 0; //make sure the curve comes back to 0

Non normal data

I need to draw a Bell Curve from this data. But not all of the datasets follow a normal deviation as in the output above.

So what would be the best approach for getting this data into a bell curve?

Can I use the standard deviation and mean of the data to calculate n coordinates along a curve, and then transpose scores onto that curve to build the charts?

or.. Should I be trying to normalise the existing data into a curve, and then interpolating adiitonal values into the dataset to make the output smooth?

Thanks for any help!

Upvotes: 1

Views: 4858

Answers (1)

mathematician1975
mathematician1975

Reputation: 21351

I am not sure if I have completely understood your requirements but this is how I interpreted your question.

If you have a set amount of observations in your set, you could calculate a histogram by partitioning the range of the data and calculating the theoretical percentage from the standardised normal variable according to this http://en.wikipedia.org/wiki/Normal_distribution#Standardizing_normal_random_variables

For example, say your mean was 5 and standard deviation 1 over a sample of 1000. Then we know that roughly 68% of a normal distribution lies within 1 S.D. either side of the mean. Therefore in your histogram bins [4,5] and [5,6] you would have 340 observations each. Similarly approximately 13% of the population lie in the intervals [mean-2xS.D,mean - 1 x S.D] and [mean + 1 x S.D,mean + 2 x S.D] . In this facile example, you would then generate observation counts of 130 in the intervals [3,4] and [6,7].

You can obviously consider finer intervals according to your needs by looking up the appropriate percentage of the population within intervals using standard normal variable tables. You would then have a ideal theoretical normal distribution sample represented in your histogram. You could then interpolate these points to get a smooth curve to overlay onto your histogra,

Upvotes: 2

Related Questions