Jump to content

Recommended Posts

 

;;;;small function -> create symmetrical lists (palindrom) with markov (for generating half-seq)

(setf transition
      '((1 (4 1) (5 1) (-6 2))
        (2 (5 2) (4 1))
        (3 (4 1))
        (4 (5 1) (2 1))
        (5 (1 3) (-6 2) (4 1))
        (-6 (4 1) (3 2))
        (7 (1 1) (-6 1))))

;;;FUNCTION

(defun gen-sym-markov (&key seq-length transition-matrix) 
 (let ((vals 0))
   ;falls seq-length = liste, werden positive werte gezählt und neu
   ;seq-length (= angepasst, formatunabhängig)
   (if (listp seq-length)
     (setq seq-length (car (last (loop for i in seq-length
                                   with cnt = 0
                                   when (> i 0)
                                   collect (incf cnt))))))
   ;entscheindung grad/ungrad
   (if (evenp seq-length)
     (progn 
       (setq vals (gen-markov-from-transitions transition-matrix :size (/ seq-length 2) :start (rnd-pick (flatten (filter-first 1 transition-matrix)))))
       (append vals (reverse vals)))

     (progn 
       (setq vals (gen-markov-from-transitions transition-matrix :size (/ (- seq-length 1) 2) :start (rnd-pick (flatten (filter-first 1 transition-matrix)))))
       (append vals (list (rnd-pick (flatten (filter-first 1 transition-matrix)))) (reverse vals))))))


;;;;EXAMPLE

(gen-sym-markov :seq-length 8 :transition-matrix transition)

 

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