Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Markov chain of patterns/islands
#1
The NerdSE's probability functions make it relatively easy to implement a Markov chain of patterns respectively islands.
Here is a recipe as to how this could be done. We start with a simple example to show the basic idea, followed by a complex example to show that it can get as complex as you wish it to Smile

Simple example:
Let's assume we have 3 islands (called A, B and C), each spanning two rows, starting on rows 002, 005 and 008 respectively [this implies rows 001, 004, 007 and 00A are empty, thus creating the 3 islands].
We will make use of the STSP (STart Sequencer Pattern) function to start each of the involved islands and will add a probability to them by means of the PRFn (PRobability percentage for the FXn effect column; n one of 1, 2, 3, 4) function.

On one track at the end of island A, B and C you enter (in the FX columns 1 and 2)
FX1 colmn FX2 colmn
PRF2 032  STSP 002
PRF2 021  STSP 005
PRF2 019  STSP 008

That will result in 25% chance of a jump to island A, B and C each and there is a 25% chance of no jump at all thus repeating the current pattern.
In other words:
The active pattern is repeated with 50% chance and each of the other patterns have a 25% chance of being executed. Adjusting the numbers after PRF2 changes these.
This is a simple example of a Markov chain for islands [Image: smile.png]


Explanation of the numbers:
PRF2 followed by a percentage:
032 is 50 in decimal, meaning 50% or 0.5
021 is 33 in decimal, meaning 33% or 0.33
019 is 25 in decimal, meaning 25% or 0.25

STSP followed by a destination:
The first digit denotes the track (one of 1-8) or the all tracks aka the row (when it is 0)
The next two digits are the row number as of the Sequencer screen
Thus when you change the track number from 0 to e.g. 3 in the above example, only track 3 (i.e. the patterns on track 3) would be involved.


How to compute the required percentages?
Here we need a little bit of math, or more precisely stochastics. We also need to understand, how the NerdSEQ is processing events.
Basically later events override earlier. Therefor when we encounter several STSP, the last one wins.
The last/3rd STSP is the one starting row 008. This has a percentage of 25% of being jumped to. Therefor row 008 is jumped to with a chance of 25%. The invers (i.e. not row 008) is that there is a 75% chance of either a previous STSP is executed, or there is no STSP at all. [this completes consideration of the 3rd FX row as of above].

The 2nd STSP is the one starting row 005. It has a percentage of 33% of being jumped to. However it is only effective in 75% of all cases (because in 25% in will be overridden by the 3rd row). This is called a conditional event [because it only happens, when the 3rd row does not trigger]. The resulting effective probability is the combination of the two events which is computed as the product of the two, i.e. 33% * 75% == 0.33 * 0.75 == 0.2475 which we round to 25%. Therefor row 005 is jumped to with a chance of 25% (rounded). The combined invers (i.e. neither row 005 nor row 008) has a percentage of 100%-25% - 24.75% = 50.25% [this completes consideration of the 2nd FX row as of above].

The 1st STSP, starting row 002, follows a very similar consideration. The basic percentage of it being jumped to is 50%. However it is only effective in 50.25% of all cases (because 25% and 24.75% are already "taken" by rows 008 and 005 respectively). Repeating the same argument about conditional events yields a percentage of 25.125% of the 1st STSP being effective thus resulting in row 002 being jumped to.
Now what happens with the remaining 25.125% that we have not yet allocated to anything?
That is the probability for the event that NONE of the STSP is executed at all [remember: all have a chance of not being executed!] and that means we simply repeat the current island [this completes consideration of the 1st FX row as of above].


Markov chain involving 10 events (9 patterns/islands named A-I and "repeat current pattern/island" for 10 events) :
On one track at the end of island A-I you enter (in the FX columns 1 and 2)
FX1 colmn FX2 colmn
PRF2 032  STSP 002
PRF2 021  STSP 005
PRF2 019  STSP 008
PRF2 014  STSP 00B
PRF2 011  STSP 00E
PRF2 00E  STSP 011
PRF2 00C  STSP 014 *)
PRF2 00B  STSP 017
PRF2 00A  STSP 01A

That will result in 10% chance (rounded) of a jump to either of the islands each and there is a 10% chance of no jump at all thus repeating the current pattern.
In other words:
The active pattern is repeated with 20% chance and each of the other patterns have a 10% chance of being executed. Adjusting the numbers after PRF2 changes these.

The computations involved are identical to the example above. Just more steps. FWIW I use a spreadsheet for it Smile

*) Instead of PRF2 00C one could as well use PRF2 00D - the resulting rounding errors would be the same but they'd happen in different direction. The precise probability would have been 0.125. I chose 00C == 0.12 over 00D == 0.13 because proper mathematical rounding of the digit 5 always goes towards the even number which in this case means rounding towards ...2 instead of rounding towards ...3.
In the end it is a matter of taste - the magnitude of the resulting error is the same for both Smile

Kind regards,
Michael
Reply
#2
This is an excellent post, thank you for this!!
Reply
#3
Super! thank you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)