[pstricks] re-using the same random variable

jmpapy Jean-Michel.Papy at esat.kuleuven.ac.be
Fri Oct 8 18:30:27 CEST 2004


Quoting Herbert Voss <Herbert.Voss at alumni.TU-Berlin.DE>:

> jmpapy wrote:
> 
> > Maybe I don't understand how the postscript language works in this
> case.
> > To me, each time the program read "rand", it returns a new integer
> 
> > randomly drawn from [0 2^31 -1]. Is it correct ? 
> 
> sure, but we always call the value of the intervall -5..5 the
> x-value. However no problem.

Yes my notation was a bit awkward and confusing. 

> Next try, the second example shows rand/2 to see that it is
> exactly the same list of random numbers.
> 

In one word : perfect !

> Herbert

Thanks a lot Herbert.


> 
> 
> \documentclass{article}
> \usepackage{pstricks,pstricks-add}
> 
> \begin{document}
> 
> \pstVerb{
>    /randReal { rand 2147483647 div } def
>    rrand srand
> }
> \psset{yunit=3cm}
> \begin{pspicture}(-5,-0.2)(5,1.5)
> \psaxes(0,0)(-5,0)(5,1)
> \psplot[linecolor=red,plotpoints=200,showpoints=true,linestyle=none]
{-5}
>      {5}{ randReal dup 2.72 exp mul } %x.e^{x}
> \end{pspicture}
> 
> \psset{yunit=1cm}
> \begin{pspicture}(-5,-0.2)(5,7)
>    \psaxes(0,0)(-5,0)(5,6)
>    \psset{plotpoints=20,linestyle=dotted,linewidth=2pt}
>    \pstVerb{  987654321 srand }
>    \psplot[linecolor=red]{-5}{5}{ randReal 6 mul } % x
>    \pstVerb{ 987654321 srand }
>    \psplot[linecolor=blue]{-5}{5}{ randReal 6 mul 2 div } % x2
> \end{pspicture}
> 
> \end{document}
> 
> 
> 
> 
> -- 
> 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