[pstricks] re-using the same random variable

Herbert Voss Herbert.Voss at alumni.TU-Berlin.DE
Fri Oct 8 16:28:42 CEST 2004


jmpapy wrote:
> Hello,
> 
> Here are two problems:
> 
> (1) How to use twice the same random variable at a time in the same 
> plot?
> for instance in the following code:
> ===============
> \begin{pspicture}(-5,-0.2)(5,2)
> \psline{-}(-5,0)(5,0)
> \psplot[linecolor=red,plotpoints=200,showpoints=true,linestyle=none]{-5}
> {5}{rand 2147483647 div rand 2147483647 div 2.72 exp mul} %x.e^{x}
> \end{pspicture}


hm, I have some problems to really understand here. The
variable x in general (xMax-xMin)/plotpoints ...

> (2) How to use twice the same random variable simultaneously in two 
> different plot ?

\documentclass{article}
\usepackage{pstricks}
\usepackage{pstricks-add}

\begin{document}

\begin{pspicture}(-5,-0.2)(5,2)
\psaxes(0,0)(-5,0)(5,2)
\psplot[linecolor=red,plotpoints=200,showpoints=true,linestyle=none]{-5}
     {5}{ rand 2147483647 div dup 2.72 exp mul } %x.e^{x}
\end{pspicture}


\begin{pspicture}(-5,-0.2)(5,7)
   \pstVerb{
     rrand srand
     rand 2147483647 div /randInt exch def
   }
   \psaxes(0,0)(-5,0)(5,6)
   \psset{plotpoints=200,linestyle=dotted,linewidth=3pt}
   \psplot[linecolor=red]{-5}{5}{ randInt 6 mul } % x
   \psplot[linecolor=blue]{-5}{5}{ randInt 6 mul sqrt } % x2
\end{pspicture}

\end{document}


I changed it only for the demo to sqrt(randInt)

Herbert



-- 
http://TeXnik.de/
http://PSTricks.de/
ftp://ftp.dante.de/tex-archive/info/math/voss/Voss-Mathmode.pdf
http://www.dante.de/faq/de-tex-faq/
http://www.tex.ac.uk/cgi-bin/texfaq2html?introduction=yes




More information about the PSTricks mailing list