forked from appinfosapienza/so-un-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
risposte.txt
60 lines (60 loc) · 1.2 KB
/
risposte.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
1.
block MarkovChain
//external function myrandom() returns a random real number in [0, 1]
parameter Real x0 = 0;
OutputReal x;
Integer countdown;
algorithm
when initial() then
x := x0;
countdown := 0;
elsewhen sample(0, 1) then
if (countdown <= 0)
then
countdown := 1 + integer(floor(10*myrandom()));
x := 1 - pre(x);
else
countdown := countdown - 1;
end if;
end when;
end MarkovChain;
2.
block MarkovChain
//external function myrandom() returns a random real number in [0, 1]
parameter Real x0 = 0;
OutputReal x;
Integer countdown;
algorithm
when initial() then
x := x0;
countdown := 0;
elsewhen sample(0, 10) then
if (countdown <= 0)
then
countdown := 1 + integer(floor(myrandom()));
x := 1 - pre(x);
else
countdown := countdown - 1;
end if;
end when;
end MarkovChain;
3.
block MarkovChain
//external function myrandom() returns a random real number in [0, 1]
parameter Real x0 = 0;
OutputReal x;
Integer countdown;
algorithm
when initial() then
x := x0;
countdown := 0;
elsewhen sample(0, 1) then
if (countdown >= 0)
then
countdown := 1 + integer(floor(10*myrandom()));
x := 1 - pre(x);
else
countdown := countdown - 1;
end if;
end when;
end MarkovChain;