[pstricks] gauss-example & histogram

Doris Behrendt doris.behrendt at me.com
Tue Nov 17 09:33:26 CET 2009


> Has anyone an idea how to add a histogram to the Gauß-Example on the  
> psticks-website?

hi,
look at this ... it's quite some time I did this and I don't know if  
it is similar enough to herberts example, but perhaps it helps...

greetings
d




\documentclass[11pt]{article}
\usepackage{amssymb}
\usepackage{ngerman}
\usepackage{textcomp}
\usepackage{sistyle}
\SIgroupfourfalse\SIstyle{German}

\linespread{1.2}
\usepackage{pstricks}
\usepackage{pst-func}
\usepackage{pst-plot}
\usepackage{pst-math}


\begin{document}




\psset{xunit=1,yunit=5}
\psframebox[framesep=0]{%(n,p)=(6,0.1), sigma=sqrt0.54=0.734847,  
mu=0.6, y_max=0.55

\begin{pspicture}(-2,-0.2)(7.5,0.75)%(-1,0)(n+1.5,y-max + etwas,  
gewichtet nach y-unit)

\psBinomial[linewidth=0.7pt%,fillstyle=solid, fillcolor=lightgray%,  
linecolor=red
]{6}{0.1}
\psaxes[linewidth=1.3pt,arrowscale=2,Dy=0.2,dy=0.2\psyunit]{->}(0,0) 
(-1.9,0)(7,0.6)
%\uput[-90](7,0){$i$}\uput[90](0,0.6){$\beta%_{\mbox{\tiny  
6}}^{\mbox{\tiny 0,4}}
%(i)$}
\rput(5,0.6){\fbox{$p=0,1\quad n=6$}}

\psGauss[linewidth=1pt, mue=0.6, sigma=0.735
]
{-2}{7}

\end{pspicture}}%bild ende, framebox zu
\hspace*{0.4cm}\fbox{\scriptsize$\sigma\approx 0,74,\ \mu=0,6,\  
npq=0,54$}
\newline

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%oben:nr1

\psframebox[framesep=0]{

\begin{pspicture}(-2,-0.2)(7.5,0.75)%(-1,0)(n+1.5,y-max + etwas,  
gewichtet nach y-unit)

\psBinomial[linewidth=0.7pt%,fillstyle=solid, fillcolor=lightgray%,  
linecolor=red
]{6}{0.3}
\psaxes[linewidth=1.3pt,arrowscale=2,Dy=0.2,dy=0.2\psyunit]{->}(0,0) 
(-1.9,0)(7,0.6)
%\uput[-90](7,0){$i$}\uput[90](0,0.6){$\beta%_{\mbox{\tiny  
6}}^{\mbox{\tiny 0,4}}
%(i)$}
\rput(5,0.6){\fbox{$p=0,3\quad n=6$}}

\psGauss[linewidth=1pt, mue=1.8, sigma=1.122
]
{-2}{7}

\end{pspicture}}%bild ende, framebox zu
\hspace*{0.4cm}\fbox{\scriptsize$\sigma\approx1,12,\ \mu=1,8,\  
npq=1,26$}
\newline

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%oben:nr2

\psframebox[framesep=0]{

\begin{pspicture}(-2,-0.2)(7.5,0.75)%(-1,0)(n+1.5,y-max + etwas,  
gewichtet nach y-unit)

\psaxes[linewidth=1.3pt,arrowscale=2,Dy=0.2,dy=0.2\psyunit]{->}(0,0) 
(-1.9,0)(7,0.6)
%\uput[-90](7,0){$i$}\uput[90](0,0.6){$\beta%_{\mbox{\tiny  
6}}^{\mbox{\tiny 0,4}}
%(i)$}
\psBinomial[linewidth=0.7pt%,fillstyle=solid,fillcolor=lightgray
]{6}{0.5}



\rput(5,0.6){\fbox{$p=0,5\quad n=6$}}
\psGauss[linewidth=1pt, mue=3, sigma=1.225
]
{-2}{7}

\end{pspicture}}%bild ende, framebox zu
\hspace*{0.4cm}\fbox{\scriptsize$\sigma\approx1,12,\ \mu=3,\ npq=6,25$}
\newline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%%%%%%%oben:nr3
\psset{xunit=0.6cm,yunit=10cm}
\psframebox[framesep=0]{%(n,p)=(20,0.1), sigma=1.342, mu=2, y_max=?

\begin{pspicture}(-4.5,-0.1)(22.5,0.55)%(-1,0)(n+1.5,y-max + etwas,  
gewichtet nach y-unit)


\psaxes 
[linewidth=1.3pt,arrowscale=2,Dy=0.2,dy=0.2\psyunit,Dx=5,dx=5\psxunit] 
{->}(0,0)(-3.9,0)(22,0.5)
\rput(15,0.45){\fbox{$p=0,1\quad n=20$}}

\psBinomial[linewidth=0.7pt]{20}{0.1}
\psGauss[linewidth=1pt, mue=2, sigma=1.342]{-4}{22}

\end{pspicture}}%bild ende, framebox zu
\mbox{}\\[1ex]\fbox{\scriptsize$\sigma\approx1,34,\ \mu=2,\ npq=1,8$}
\newline

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%oben:nr4

\psframebox[framesep=0]{

\begin{pspicture}(-4.5,-0.1)(22.5,0.55)%(-1,0)(n+1.5,y-max + etwas,  
gewichtet nach y-unit)

\psaxes 
[linewidth=1.3pt,arrowscale=2,Dy=0.2,dy=0.2\psyunit,Dx=5,dx=5\psxunit] 
{->}(0,0)(-3.9,0)(22,0.5)
\rput(15,0.45){\fbox{$p=0,3\quad n=20$}}

\psBinomial[linewidth=0.7pt]{20}{0.3}
\psGauss[linewidth=1pt, mue=6, sigma=2.05]{-4}{22}

\end{pspicture}}%bild ende, framebox zu
\mbox{}\\[1ex]\fbox{\scriptsize$\sigma\approx2,05,\ \mu=6,\ npq=4,2$}
\newline

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%oben:nr5

\psframebox[framesep=0]{

\begin{pspicture}(-4.5,-0.1)(22.5,0.55)%(-1,0)(n+1.5,y-max + etwas,  
gewichtet nach y-unit)

\psaxes 
[linewidth=1.3pt,arrowscale=2,Dy=0.2,dy=0.2\psyunit,Dx=5,dx=5\psxunit] 
{->}(0,0)(-3.9,0)(22,0.5)
\rput(15,0.45){\fbox{$p=0,5\quad n=20$}}

\psBinomial[linewidth=0.7pt]{20}{0.5}
\psGauss[linewidth=1pt, mue=10, sigma=2.232]{-4}{22}

\end{pspicture}}%bild ende, framebox zu
\mbox{}\\[1ex]\fbox{\scriptsize$\sigma\approx2,23,\ \mu=10,\ npq=5$}
\newline


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%oben: nr6
\psset{xunit=0.3cm,yunit=30cm}
\psframebox[framesep=0]{%(n,p)=(20,0.1), sigma=1.342, mu=2, y_max=?

\begin{pspicture*}(-10,-0.03)(30,0.17)%(-1,0)(n+1.5,y-max + etwas,  
gewichtet nach y-unit)


\psaxes 
[linewidth 
=1.3pt,arrowscale=2,%Dy=0.05,dy=0.05\psyunit,Dx=10,dx=10\psxunit
Dy=0.05,Dx=5
]{->}(0,0)
(-5,0)(25,0.15)
\rput(20,0.1){\fbox{$p=0,1\quad n=100$}}

\psBinomial[linewidth=0.7pt]{100}{0.1}
\psline[linecolor=white,linewidth=2pt](25,0)(29.9,0)
\psGauss[linewidth=1pt, mue=10, sigma=3]{-5}{25}

\end{pspicture*}}%bild ende, framebox zu
\mbox{}\\[1ex]\fbox{\scriptsize$\sigma=3,\ \mu=10,\ npq=9$}
\newline

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%oben:nr7

\psframebox[framesep=0]{

\begin{pspicture*}(10,-0.03)(50,0.15)%(-1,0)(n+1.5,y-max + etwas,  
gewichtet nach y-unit)

\rput(40,0.1){\fbox{$p=0,3\quad n=100$}}

\psaxes 
[linewidth 
=1.3pt,arrowscale=2,%Dy=0.05,dy=0.05\psyunit,Dx=10,dx=10\psxunit
Dy=0.05,Dx=5]{->}(0,0)
(15,0)(45,0.15)


\psBinomial[linewidth=0.7pt]{100}{0.3}
\psline[linecolor=white,linewidth=50pt](0,0)(14.95,0)
\psline[linecolor=white,linewidth=2pt](45,0)(49.9,0)
\psGauss[linewidth=1pt, mue=30, sigma=4.5826]{15}{45}

\psaxes[linewidth=1.3pt,showorigin=false,Dy=0.05,dy=0.05\psyunit
](15,0)(15,0)(15,0.12)
\psaxes[xAxis=false,linewidth=1.3pt,labels=none,arrowscale=2
]{->}(15,0)(15,0)(15,0.125)


\end{pspicture*}}%bild ende, framebox zu
\mbox{}\\[1ex]\fbox{\scriptsize$\sigma\approx4,58,\ \mu=30,\ npq=21$}
\newline

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%oben:nr8

\psframebox[framesep=0]{

\begin{pspicture*}(30,-0.05)(70,0.15)%(-1,0)(n+1.5,y-max + etwas,  
gewichtet nach y-unit)
\rput(60,0.08){\fbox{$p=0,5\quad n=100$}}

\psaxes 
[linewidth 
=1.3pt,arrowscale=2,Dy=0.05,dy=0.05\psyunit,Dx=10,dx=10\psxunit]{->} 
(0,0)
(33,0)(68,0.15)


\psaxes[xAxis=false,linewidth=1.3pt,labels=none,arrowscale=2]{->}(35,0) 
(35,0)(35,0.13)
\psaxes[linewidth=1.3pt,showorigin=false,Dy=0.05](35,0)(35,0)(35,0.125)

\psBinomial[linewidth=0.7pt]{100}{0.5}
\psGauss[linewidth=1pt, mue=50, sigma=5]{35}{68}

\psline[linecolor=white,linewidth=50pt](0,0)(32.95,0)
\psline[linecolor=white,linewidth=50pt](68,0)(69.9,0)

\end{pspicture*}}%bild ende, framebox zu
\mbox{}\\[1ex]\fbox{\scriptsize$\sigma=5,\ \mu=50, npq=25$}


\end{document}



\makeatletter
\def\psGaussFill{\pst at object{psGaussFill}}
\def\psGaussFill at i(#1,#2)(#3,#4)#5#6{{
   \pst at killglue
   \use at par
   \pscustom[linestyle=none]{%
     \psline(#4,0)(#3,0)
     \psplot[liftpen=1]{#3}{#4}{x #5 #6 GAUSS}%
   }%
   \psplot[fillstyle=none]{#1}{#2}{x #5 #6 GAUSS}%
}\ignorespaces}
\makeatother




More information about the PSTricks mailing list