[pstricks] [Fwd: Re: binom_distribution]

Herbert Voss Herbert.Voss at alumni.TU-Berlin.DE
Sun Apr 16 14:11:56 CEST 2006


-------- Original Message --------
Subject: Re: binom_distribution
Date: Sun, 16 Apr 2006 13:28:23 +0200
From: Herbert Voss <Herbert.Voss at gmx.net>
Newsgroups: comp.text.tex
References: <Oud0g.25228$7a.4617 at pd7tw1no>

John Campbell wrote:
> Sorry if this a FAQ, but is there an simple way to use ps-plot to make a 
> binomial distribution, or should I just get the data, and use multido?

here is a PSTricks solution which gives this output:
http://perce.de/temp/binom.pdf
If it really helps, I'll put into pst-func.

Herbert



\documentclass[12pt]{article}%
\usepackage{pstricks}%
\usepackage{pst-func}%
%
\makeatletter
\def\psBinom{\pst at object{psBinom}}
\def\psBinom at i#1{%
   \begin at SpecialObj%
   \addto at pscode{
     /scx { \pst at number\psxunit mul } def
     /scy { \pst at number\psyunit mul } def
     /BinScale { scy 2 N exp div exch N div scx exch } def
     /N #1 def
     /Y 1 def
     0 0 moveto
     /kOld 0 def
     1 1 N {
       /k exch def
       /Y Y N k sub 1 add mul k div def
       kOld Y BinScale L k Y BinScale L
       \ifPst at markZeros k 0 BinScale L \fi
       /kOld k def
     } for
   stroke
   }%
   \end at SpecialObj%
}
\makeatother

\begin{document}

\psset{yunit=30,xunit=15}
\begin{pspicture}(1,.25)
\psaxes[Dx=0.1,dx=0.1\psxunit,Dy=0.05,dy=0.05\psyunit]{-|}(1,.25)
\psBinom[markZeros]{9}% option defined in pst-func
\psset{linewidth=1pt}
\psBinom[linecolor=green]{25}
\psBinom[linecolor=blue]{50}
\psBinom[linecolor=red]{100}
\end{pspicture}

\end{document}






More information about the PSTricks mailing list