Group Admins

  • Profile picture of Karim
  • Profile picture of Jean

OpenMusic

Public Group active 1 day ago

User group for OpenMusic and computer-aided composition. Visit the Forum for discussions.

Markov not working

Author 2 Subscribed Users |
Profile photo of Frank GRATKOWSKI
Frank GRATKOWSKI

Hello, it seems that the markov1 and markov2 functions in the alea library are not working anymore.
when I have ((0.0 0.5 0.5) (0.5 0.0 0.5) (0.5 0.5 0.0)) in the first input I should get random numbers 1-3 with repetition but I get many repeats.
Am I doing something wrong?

Thanks

Frank

May 15, 2018 at 15:02 #26547
Profile photo of Mikhail Malt
Mikhail Malt

Hi Frank,

I just checked it now, with your data, and seems that it is working fine….
To be sure we are speaking about the same thing.
Let remember that <markov1>, given a matrix and an <index> (sorry, it is old and first element = 1), just return the next element. One at once.
To check if <markov1> is working properly, in your case is enough do not have the same index than <index>. I checked it with 1, 2 and 3…
For example, with <index> = 1
OM => (2 2 3 3 2 2 2 3 3 3 2 2 2 3 3 2 2 3 2 2 3 3 2 2 2 2 2 2 3 3 2 2 2 3 2 2 3 2 3 2 2 2 2 3 3 2 2 3 3 3 2 2 2 3 3 3 3 3 3 3 2 3 2 3 3 3 2 3 3 2 2 3 3 2 2 2 2 3 2 3 2 3 3 2 3 3 2 3 2 3 2 2 2 3 3 2 3 3 3 2)
with <index> = 2
OM => (1 3 3 1 3 3 3 3 1 1 3 1 1 1 3 3 3 3 1 1 3 3 1 1 1 1 3 3 3 3 3 1 3 1 1 3 3 3 3 3 1 3 3 1 1 3 1 3 1 1 1 3 3 1 1 1 1 3 1 1 1 1 3 1 1 3 3 1 1 1 1 1 1 3 3 1 1 3 1 1 1 1 1 1 3 1 1 3 1 1 3 1 3 3 1 1 1 3 1 3)
with <index> = 3
OM => (1 1 2 2 1 2 2 2 1 1 2 2 2 1 1 2 2 2 2 1 2 2 1 1 1 1 2 2 1 1 1 1 2 1 1 2 2 2 2 2 2 1 1 2 2 1 1 1 2 1 1 1 1 2 1 2 1 2 2 1 1 1 1 1 1 1 1 2 2 1 1 2 2 1 2 1 2 2 1 1 2 2 2 1 1 1 1 1 2 1 2 1 2 1 1 1 2 2 2 1)

if you have repeated elements, in this first example, it is just means that you are trowing your dices again from the same index…

seems ok, no ?

for <markov2>, with your matrix, <first element> = 1, and length size of the sequence = 200
OM => (1 3 2 3 2 3 1 3 1 3 1 2 1 2 1 2 1 3 2 1 2 1 3 2 3 1 2 3 1 3 2 1 2 3 2 1 3 2 3 2 1 2 3 2 1 2 3 2 1 3 2 3 2 3 1 3 2 3 1 3 2 3 1 3 2 1 2 1 2 1 2 3 2 1 3 2 1 2 3 2 1 2 3 2 3 2 3 1 3 1 2 1 2 3 1 2 3 2 1 3 2 3 2 3 2 3 2 1 3 2 3 1 3 1 2 3 2 3 2 3 2 1 3 2 3 2 3 1 3 1 3 1 3 2 3 2 3 2 3 1 3 2 1 2 3 1 3 1 3 2 3 1 3 1 3 2 3 1 3 2 3 2 1 3 2 3 1 3 1 3 1 3 1 2 1 2 1 3 1 3 1 3 1 3 2 1 2 1 2 3 2 1 2 3 1 2 3 1 3 1)

the same seems to work properly…

all the best

Mikhail

May 15, 2018 at 15:22 #26548
Profile photo of Frank GRATKOWSKI
Frank GRATKOWSKI

Thanks Mikhail,

I think I got it. Is there any way to safe the last state, so if I evaluate markov2 again it should continue with a first element relating to the table which means in the example ((0.0 0.5 0.5) (0.5 0.0 0.5) (0.5 0.5 0.0)) if the sequence ends with 1 it shouldn’t start with one. Instead either with 2 or 3. A lisp code solution would be fine. I guess it might be easier…

thanks
Frank

May 15, 2018 at 15:59 #26551
Profile photo of Frank GRATKOWSKI
Frank GRATKOWSKI

I think the easiest way would be if the last element of the previous call should be the new first element and the result will be each time butlast..

May 15, 2018 at 16:06 #26552

You must be logged in to reply to this topic.

Log in now