[metapost] Drawing a urn
technik at roomandspace.com
Thu Nov 29 13:09:53 CET 2007
I'd like to draw an urn where we have a probability of .57 to get a dark
ball when we choose a random ball.
I have the following:
u := 5mm;
s := .05u;
--(9.5u+2s,0)..(9.85u+2s,.15u)..(10u+2s,.5u)--(10u+2s , 10u+s);
for i=1 upto 10:
for j=1 upto 10:
c := fullcircle scaled 1u shifted (j*u-u/2+s,i*u-u/2+s);
if (i <= 5 ):
fill c withcolor .7white;
fill c withcolor .4white;
This looks nice, but it shows a fifty-fifty chance. How would you go
further to show a chance of .57 instead of .5?
Second: !important! I'd like to have the balls randomized. In a java
application I do the same by creating 100 boolean values (true = dark,
false = white) something like
for i=1 upto 100:
if i <= .57:
How could that be done correctly with metapost?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://tug.org/pipermail/metapost/attachments/20071129/1b917411/attachment.bin
More information about the metapost