[pstricks] second update for psPoisson

halbard7 at aol.com halbard7 at aol.com
Sun Aug 26 03:37:25 CEST 2007


Dear Herbert,

Thanks for your instructions, which I have followed assiduously, I hope. Try this code on for size.

------
\def\psPoisson{\pst at object{psPoisson}}%
\def\psPoisson at i#1#2{\psPoisson at ii#1,,\@nil{#2}}%
\def\psPoisson at ii#1,#2,#3\@nil#4{%
?\def\pst at tempA{#2}%
?\ifx\pst at tempA\@empty\psPoisson at iii{0}{#1}{#4}\else
? \psPoisson at iii{#1}{#2}{#4}\fi}%
\def\psPoisson at iii#1#2#3{%
? \begin at SpecialObj%
? \addto at pscode{
??? /scx { \pst at number\psxunit mul } def
??? /scy { \pst at number\psyunit mul } def
??? /M #1 def
??? /N #2 def
??? /lambda #3 def
??? /elambda Euler #3 neg exp def? % e^-lambda
??? /dx \psFunc at barwidth 2 div def
??? /kOld dx neg M add def % addition of M here
??? kOld scx 0 moveto?? % starting point
??? /Y elambda def??? % start value
??? 0 1 M 1 sub {?? % skip over first M-1 rectangles
????? /k exch def? % whilst recursing probabilities
????? k 0 eq { /Y elambda def }{ /Y Y lambda mul k div def } ifelse
??? } for % nothing happens if M=0
??? M 1 N {???????????? % N-M+1 times
????? /k exch def?????? % save loop variable
????? k 0 eq { /Y elambda def }{ /Y Y lambda mul k div def } ifelse
????? kOld scx 0 L kOld scx Y scy L k dx add scx Y scy L
????? \ifPst at markZeros k dx add scx 0 L \fi
????? \ifPst at printValue
??????? gsave \psk at PSfont findfont \psk at fontscale scalefont setfont
??????? Y \psk at valuewidth string cvs
??????? k scx \psk at fontscale 2 div add
??????? Y scy \pst at number\pslabelsep add moveto
??????? 90 rotate show grestore
????? \fi
????? /kOld kOld 1 add def
??? } for
??? \ifPst at markZeros\else k dx add scx 0 L \fi % last line down to x-axis
? }%
? \psk at fillstyle
? \pst at stroke
? \end at SpecialObj%
}
------

It seems to work, e.g. \psPoisson{45}{30}, \psPoisson{20,45}{30}, even \psPoisson{25,25}{30}. No more psclip (yippee! ) Anything untoward is a bug, not a feature. If you agree, then \psBinomial is next.

Yours,

Gerry Coombes


________________________________________________________________________
Get a FREE AOL Email account with unlimited storage.  Plus, share and store photos and experience exclusively recorded live music Sessions from your favourite artists. Find out more at http://info.aol.co.uk/joinnow/?ncid=548.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tug.org/pipermail/pstricks/attachments/20070825/d68498e1/attachment.html 


More information about the PSTricks mailing list