[pstricks] random points

Herbert Voss Herbert.Voss at FU-Berlin.DE
Fri Jun 23 20:27:39 CEST 2017


Am 23.06.2017 um 17:42 schrieb Denis Vergès:

> I had to plot 100 random points  in a square 0 <= x < =1 and 0 <= y <= 1.
> 
> In fact  if the point is under the curve \psplot[plotpoints=3000,linewidth=1.25pt,linecolor=cyan]{0}{1}{1 x dup mul 1 add div}
> the point is black  ; if the point is above the point is white.

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

\begin{document}
\psset{unit=5cm}
\begin{pspicture}(-0.1,-0.1)(1.1,1.1)
\psRandom[dotsize=4pt,dotstyle=o,fillstyle=solid,fillcolor=black,
   randomPoints=100](0,0)(1,1){%
     \pscustom[linestyle=none]{%
       \psline(0,1)
       \psplot[plotpoints=200]{0}{1}{1 x dup mul 1 add div }
       \psline(1,0)
}}
\psplot[linecolor=red,linewidth=1.5pt]{0}{1}{1 x dup mul 1 add div }
\psaxes[dx=0.2,dy=0.2,Dx=0.2,Dy=0.2]{->}(0,0)(-0.1,-0.1)(1.1,1.1)
\end{pspicture}

\end{document}

Herbert


-------------- next part --------------
A non-text attachment was scrubbed...
Name: Bildschirmfoto vom 2017-06-23 20-26-50.png
Type: image/png
Size: 11969 bytes
Desc: not available
URL: <http://tug.org/pipermail/pstricks/attachments/20170623/ad9d0297/attachment.png>


More information about the PSTricks mailing list