# [pstricks] [Fwd: Re: binom_distribution]

Poul Riis Poul.Riis at skolekom.dk
Mon Apr 17 10:22:30 CEST 2006

To my knowledge a binomial distribution is defined for integral values
only.
I don't fully understand why the following seems to work...
- And furthermore, I don't understand why it doesn't work for all values
of n and p!?
Who can improve it?

Yours,
Poul Riis

\documentclass[a4paper,12pt]{article}
\usepackage{pst-func}
\usepackage{multido}
\pagestyle{empty}

\newcommand{\binomialdistr}[2]{%
\pstVerb{%
/nn #1 def%
/pp #2 def%
/prob 1 pp sub nn exp def%
}%
\psset{xunit=1cm,yunit=5cm}%
\begin{pspicture}(0,0)(#1,1)%
\SpecialCoor%
\psaxes[ticksize=-2pt 0,Dy=0.1]{->}(0,0)(0,0)(#1,1)%
\psline[linecolor=red,linewidth=3pt](!0 0)(!0 prob)%
\uput[90]{90}(!0
prob){\psPrintValue[valuewidth=10,fontscale=8,linecolor=blue]{prob}}%
\multido{\nj=0+1}{#1}{%
\pstVerb{%
/probold prob def%
/prob pp 1 pp sub div nn \nj\space sub mul \nj\space 1 add div probold mul
def%
}%
prob)%
prob){\psPrintValue[valuewidth=10,fontscale=8,linecolor=blue]{prob}}%
}%
\end{pspicture}%
}%

\begin{document}
Binomial distribution with pstricks....\\[1cm]
\binomialdistr{6}{0.4}
\end{document}

-------------- next part --------------

###########################################
Denne meddelelse med evt. vedlæg  er scannet af SkoleKom ved hjælp af F-Secure virusscanner.

Meddelelsen kan læses sikkert. Det kán i sjældne tilfælde være kritisk at hente vedlæg.
Kontakt din systemadministrator, hvis du er i tvivl.

For yderligere information,
http://forside.skolekom.dk/indhold/punkt1/viruspolitik