Calculate each point of my Gauss curve

169 Views Asked by At

I'm coding a program which calculates the confidence interval. He takes the population and a sample of the population as parameters, and the percent of people of that sample who answered "yes" to a survey.

for example I've got that :

Population : 10000

Sample : 500

Percent of "yes" : 42.24 %

I run the program and than I've got my results :

At 99 % : 5.56 % [ 36.68 % ; 47.80 % ]

At 95 % : 4.22 % [ 38.02 % ; 46.46 % ]

And I would like to display a Gauss curve too. That's where I'm stuck. If any one have any ideas, would be great !

1

There are 1 best solutions below

0
On BEST ANSWER

To plot a Gaussian, you need the mean and median. The mean is 42.24. The median can be inferred from your confidence interval: the 95% confidence interval has half-size $1.96\, \sigma$. So, for the plot you can use $$\sigma = \frac{46.46-38.02}{2\cdot 1.96}\approx 2.15$$ Now it remains to plot $$y=\frac{1}{\sqrt{2\pi}\cdot 2.15} \exp\left\{-\frac{(x-42.24)^2}{2\cdot 2.15^2}\right\} $$

gauss