Jump to content

multiple-markov - changing context-size/level


Recommended Posts

hi all,

i coded a little markov-program who changes the LEVEL-size if necessary to generate the number of values you want exactly.

 

it would be nice if someone could check/test the IDEA, and if it's correct and makes sense :-)

 

the markov starts on LEVEL 3 and tries to generate a number of output-levels with its TRANSITION-rules (level-3-rules), if it's possible (=generating the size) everything's fine. but if it's not possible, then the programm changes on LEVEL-2-rules ... if this is also not possible (to generate the size) then it changes to LEVEL 1... 

 

here is the code...

 

;;;FUNCTION

(defun gen-multiple-markov (sequence &key size)
  (let ((transitions-level-1 (gen-markov-transitions sequence :level 1)) ;; gen transition-table level-1
        (transitions-level-2 (gen-markov-transitions sequence :level 2)) ;; gen transition-table level-2
        (seq (gen-markov-from-transitions (gen-markov-transitions sequence :level 3) :size size))) ;; gen markov-seq on level-3

    (if (< (length seq) size) ;; test if seq is too short (/= (length seq) size)
      (progn ;; if too short -> combine the last seq with a new one (level 2)
        (setq seq (append seq (gen-markov-from-transitions transitions-level-2 :size (- size (length seq)) :start (last seq))))
        (if (< (length seq) size) ;; same test as above
          (append (append seq (gen-markov-from-transitions transitions-level-1 :size (- size (length seq)) :start (last seq))))
          (append seq)))
                      
      (append seq))))

                      
                      
;;;TEST
                      
(gen-multiple-markov '(1 2 3 2 1 2 3 2 1 2 2 2 2 1 1 1 1 2 2 3 2 1 1 2) :size 36)
          
    

 

best wishes and THANX

andré

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

Terms of Use Privacy Policy