plotting a normal distribution curve

View: New views
5 Messages — Rating Filter:   Alert me  

plotting a normal distribution curve

by Shanks N :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I'm trying to make a picture similar to

http://en.wikipedia.org/wiki/Image:Standard_deviation_diagram.png

using tikz.

A search on google revealed y= (1/A)*EXP( (-x**2)/B ) sort of
approximates the normal curve.  I plugged this into an awk script and
generated the data from  x= -4 to +4.

Now, How do I plot this using Latex/Tikz to get something similar to the
picture?

regards,
shanks


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Latex-beamer-users mailing list
Latex-beamer-users@...
https://lists.sourceforge.net/lists/listinfo/latex-beamer-users

Re: plotting a normal distribution curve

by Paul Smith :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 7/4/06, Shanks N <shanks.n@...> wrote:
> I'm trying to make a picture similar to
>
> http://en.wikipedia.org/wiki/Image:Standard_deviation_diagram.png

PSTricks would do that. Have a look at the example at:

http://tug.org/PSTricks/main.cgi?file=pst-plot/examples

Paul

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Latex-beamer-users mailing list
Latex-beamer-users@...
https://lists.sourceforge.net/lists/listinfo/latex-beamer-users

Re: plotting a normal distribution curve

by Till Tantau-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Am 04.07.2006 um 20:21 schrieb Shanks N:

> Hello,
>
> I'm trying to make a picture similar to
>
> http://en.wikipedia.org/wiki/Image:Standard_deviation_diagram.png
>
> using tikz.
>
> A search on google revealed y= (1/A)*EXP( (-x**2)/B ) sort of
> approximates the normal curve.  I plugged this into an awk script and
> generated the data from  x= -4 to +4.
>
> Now, How do I plot this using Latex/Tikz to get something similar  
> to the
> picture?
>
> regards,
> shanks
>
>
> Using Tomcat but need to do more? Need to support web services,  
> security?
> Get stuff done quickly with pre-integrated technology to make your  
> job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache  
> Geronimo
> http://sel.as-us.falkag.net/sel?
> cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Latex-beamer-users mailing list
> Latex-beamer-users@...
> https://lists.sourceforge.net/lists/listinfo/latex-beamer-users

Hi!

try this (with gnuplot installed and working):


\begin{tikzpicture}[scale=1.25]
   \colorlet{col1}{blue!70}
   \colorlet{col2}{blue!60}
   \colorlet{col3}{blue!50}
   \colorlet{col4}{blue!40}

   \draw [help lines] (-4.25,-1.25) grid (4.25,1.5);
   \draw [help lines,step=0.25cm] (-2.99,0) grid (2.99,0.99);

   \draw[->] (0,-1.25) -- (0,1.5) node [above]
     {$\displaystyle\frac{1}{\sigma\sqrt{2\pi}}\exp\biggl(\frac{-x^2}
{2\sigma^2}\biggr)$};

   \begin{scope}[smooth,draw=gray!20,y=0.3989422804cm]
     \filldraw [fill=col3] plot[id=f1,domain=-3:-2] function {exp(-
x*x/2)} -- (-2,0) -- (-3,0) -- cycle;
     \filldraw [fill=col2] plot[id=f2,domain=-2:-1] function {exp(-
x*x/2)} -- (-1,0) -- (-2,0) -- cycle;
     \filldraw [fill=col1] plot[id=f3,domain=-1:0]  function {exp(-
x*x/2)} -- (0,0)  -- (-1,0) -- cycle;
     \filldraw [fill=col1] plot[id=f4,domain=0:1]   function {exp(-
x*x/2)} -- (1,0)  --  (0,0) -- cycle;
     \filldraw [fill=col2] plot[id=f5,domain=1:2]   function {exp(-
x*x/2)} -- (2,0)  -- (1,0) -- cycle;
     \filldraw [fill=col3] plot[id=f6,domain=2:3]   function {exp(-
x*x/2)} -- (3,0)  -- (2,0) -- cycle;

     \draw[black] plot[id=f7,domain=-4.25:4.25,samples=100] function  
{exp(-x*x/2)};
   \end{scope}


   \draw[->] (-4.25,0) -- (4.25,0) node [right] {$x$};

   \foreach \pos/\label in {-3/$-3\sigma$,-2/$-2\sigma$,-1/$-\sigma$,
1/$\sigma$,2/$2\sigma$,3/$3\sigma$}
     \draw (\pos,0) -- (\pos,-0.1) (\pos cm,-3ex) node
[anchor=base,fill=white,inner sep=1pt]  {\label};

   \draw (-0.1,1) -- (.1,1) node [right,fill=white,inner sep=1pt] {$
\sigma$};

   \foreach \pos/\percent/\height in  
{1/34/0.5,2/14/0.25,3/2/0.125,4/0.1/0.1}
   {
     \node[text=col
\pos,anchor=base,yshift=2pt,xshift=-0.625cm,fill=white,inner sep=1pt]  
at (\pos,\height) {$\percent\%$};
     \node[text=col\pos,anchor=base,yshift=2pt,xshift=.
625cm,fill=white,inner sep=1pt]  at (-\pos,\height) {$\percent\%$};
   }
\end{tikzpicture}


Best regards,
Till

--
Prof. Dr. Till Tantau <tantau@...>
http://www.tcs.uni-luebeck.de




Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Latex-beamer-users mailing list
Latex-beamer-users@...
https://lists.sourceforge.net/lists/listinfo/latex-beamer-users

Parent Message unknown Re: plotting a normal distribution curve

by Till Tantau-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Am 06.07.2006 um 16:17 schrieb Shanks N:

>
>
>
> Till Tantau <tantau@...> writes:
>
> Many thanks, it works perfectly!  I have a couple of questions
> regarding  the code, inline below.  I'd be grateful, if you could
> explain how you arrived at the constants in the code, the ones I have
> asked inline.
>
> [...]
>
>
>>   \begin{scope}[smooth,draw=gray!20,y=0.3989422804cm]
>
> Please, can you explain the reason for the y value above?
>

That's easy: it's 1/\sqrt(2\pi) (if I remember correctly...).

>
> [...]
>
>>   \foreach \pos/\label in {-3/$-3\sigma$,-2/$-2\sigma$,-1/$-\sigma$,
>> 1/$\sigma$,2/$2\sigma$,3/$3\sigma$}
>>     \draw (\pos,0) -- (\pos,-0.1) (\pos cm,-3ex) node
>> [anchor=base,fill=white,inner sep=1pt]  {\label};
>
> & this \draw command in the loop above?

The draw is used for the little ticks for the labels. The (\pos  
cm,-3ex) is used for correct positioning of the label.

>
>>
>>   \draw (-0.1,1) -- (.1,1) node [right,fill=white,inner sep=1pt] {$
>> \sigma$};
>>
>>   \foreach \pos/\percent/\height in
>> {1/34/0.5,2/14/0.25,3/2/0.125,4/0.1/0.1}
>>   {
>>     \node[text=col
>> \pos,anchor=base,yshift=2pt,xshift=-0.625cm,fill=white,inner sep=1pt]
>> at (\pos,\height) {$\percent\%$};
>
> & the x & y shift in this triple loop? and the inner sep one too?

The inner sep is used to reduce the white area (default of inner sep  
is 1ex). The shifts are needed so that the nodes are but where I want  
them ("finetuning").

I suggest fooling around with the values to get a feeling. They are  
also documented in the user guide.

Best regards,
Till

--
Prof. Dr. Till Tantau <tantau@...>
http://www.tcs.uni-luebeck.de




Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Latex-beamer-users mailing list
Latex-beamer-users@...
https://lists.sourceforge.net/lists/listinfo/latex-beamer-users

Re: tikz and pst-vue3d

by Alain Matthes-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hello:)
with pdflatex and latex , i've a problem if i use pst-vue3d and tikz
together (error : keyval: tikz undefined)

Alain Matthes

\documentclass[a4paper,11pt,oneside]{article}
\usepackage[utf8]{inputenc}

\usepackage{tikz}
\RequirePackage{%
                pstricks-add,%
                pst-text,%
                pst-tree,%
                pst-3dplot,%
                pst-node,%
 %               pst-vue3d%
                }

\usepackage[frenchb]{babel}

\begin{document}

Essayons de faire ce patron de cône... !

\begin{tikzpicture}[scale=.5]
\draw (0,0) node[above] {O}--(190:6cm) node[above]{$A$} arc(190:310:6cm)
node[above]{B}-- cycle;
\draw (220:6cm) +(220:3cm) circle (3cm);
\draw (220:6cm) ++(220:3cm) -- +(320:3cm) node[above,
midway,sloped]{$4~cm$};
\draw (0,0) -- +(190:6cm) node[above,midway,sloped]{$6~cm$};
\end{tikzpicture}

\end{document}  




-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Latex-beamer-users mailing list
Latex-beamer-users@...
https://lists.sourceforge.net/lists/listinfo/latex-beamer-users