< Back to IRCAM Forum

Markov not working

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

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 , given a matrix and an (sorry, it is old and first element = 1), just return the next element. One at once.
To check if is working properly, in your case is enough do not have the same index than . I checked it with 1, 2 and 3…
For example, with = 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 = 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 = 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 , with your matrix, = 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

markov-question.omp (2.58 KB)

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

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…