<pre>
model System
parameter Integer F1 = 1;
parameter Integer F2 = 2;
parameter Integer F3 = 3;
parameter Integer End = 4;
parameter Real p = 0.3;
parameter Real A[4, 4] =
[
0, 1, 0, 0;
p, 1-p, 0, 0;
0, 0, p, 1-p;
0, 0, 0, 1
];
Integer x;  Real r1024;
Integer state1024[Modelica.Math.Random.Generators.Xorshift1024star.nState];
algorithm
when initial() then
state1024 := Modelica.Math.Random.Generators.Xorshift1024star.initialState(614657, 30020);
x := F1;
r1024 := 0;
elsewhen sample(0,1) then
(r1024,state1024) := Modelica.Math.Random.Generators.Xorshift1024star.random(pre(state1024));
if (r1024 <= A[x, F1]) then
 x := F1;
 elseif (r1024 <= A[x, F1] + A[x, F2]) then
 x := F2;
 elseif (r1024 <= A[x, F1] + A[x, F2] + A[x, F3]) then
 x := F3;
 else
 x := End;
end if;
end when;
end System;
</pre>