Add 06/21 by Matteo

This commit is contained in:
Marco Realacci 2022-11-14 16:30:34 +01:00
parent 970467fe89
commit 1be2085d94
169 changed files with 962 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View file

@ -0,0 +1,33 @@
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] =
[
p, 1-p, 0, 0;
p, 0, 1-p, 0;
p, 0, 0, 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;

View file

@ -0,0 +1,3 @@
img=https://i.imgur.com/cHaHubX.png
Si consideri la seguente Markov Chain:
Quale dei seguenti modelli Modelica fornisce un modello ragionevole per la Markov Chain di cui sopra?

View file

@ -0,0 +1,33 @@
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] =
[
p, 0, 1-p, 0;
0, p, 1-p, 0;
p, 0, 0, 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;

View file

@ -0,0 +1,33 @@
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] =
[
p, 0 , 1-p, 0;
p, 1-p, 0, 0;
p, 0, 0, 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;