Post Reply 
Ehrenfest's urn
12-29-2021, 11:11 PM
Post: #2
RE: Ehrenfest's urn
(12-29-2021 10:16 PM)zahi48g Wrote:  Ehrenfest's urn
Hi Everyone (from France )

I'm trying this algorythm on my prime without success , of course i've tried to debug .

EXPORT EHRENFEST1()
BEGIN
LOCAL n,p,K;
INPUT(p);
L1:={1,2};
L2:={};
FOR K FROM 1 TO p DO
n:=RANDINT(1,2);
IF L1(1)==n OR L1(2)==n THEN
L1:=SUPPRESS(L1,n);
L2:=INSERT(L2,1,n);
ELSE
L2:=SUPPRESS(L2,n);
L1:=INSERT(L1,1,n);
END;
END;
PRINT(L1);
PRINT(L2);
END;

Could you help me ?
It seems that the problem occurs when i write " n:=RANDINT(1,2); " .

Thank you .

L2 only has one element. If n=2 you get an error when you try to SUPPRESS L2(n) since L2(2) doesn't exist.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Ehrenfest's urn - zahi48g - 12-29-2021, 10:16 PM
RE: Ehrenfest's urn - toml_12953 - 12-29-2021 11:11 PM
RE: Ehrenfest's urn - zahi48g - 12-29-2021, 11:53 PM
RE: Ehrenfest's urn - Didier Lachieze - 12-30-2021, 05:28 AM
RE: Ehrenfest's urn - John Keith - 12-30-2021, 10:30 PM
RE: Ehrenfest's urn - zahi48g - 01-03-2022, 11:10 PM
RE: Ehrenfest's urn - toml_12953 - 01-04-2022, 02:09 AM



User(s) browsing this thread: 1 Guest(s)