How do I plot normal distribution

5.6k Views Asked by At

If I know the range (1-24) and know the area (X), how can I plot a normal distribution so that the curve has area X?

1

There are 1 best solutions below

0
On BEST ANSWER

Here is how you would plot a normal distribution in Matlab for different $i = \mu$ and $j = \sigma$.

x = linspace(-10, 10, 5000);

for i = 0:1:5
    for j = 1:1:6
        n = 1/(j^2*sqrt(2*pi))*exp(-(x - i)^2/(2*j^2));
        hold on
        plot(x,n)
    end
end

So I plotted $\mu = 0, 1, \ldots, 5$ against $\sigma = 1,2,\ldots, 6$. If you want to plot just $\mu = 0$ and $\sigma = 1$, then you would do

x = linspace(-5, 5, 5000);

n = 1/(1^2*sqrt(2*pi))*exp(-(x - 0)^2/(2*1^2));
plot(x, n)

enter image description here


In Mathematica (this is slow), but you can do

Show[Table[
  Plot[1/(j^2 Sqrt[2 \[Pi]]) Exp[-(x - i)^2/(2 j^2)], {x, -10, 15}, 
   PlotRange -> {{-10, 15}, {0, 0.4}}, AspectRatio -> 1,ColorFunction -> "Rainbow"], {x, -10, 
   15}, {i, 0, 5}, {j, 1, 6}]]

and for just one instance

Plot[1/(1^2 Sqrt[2 \[Pi]]) Exp[-(x - 0)^2/(2 1^2)], {x, -3, 3}]

enter image description here