Jump to content

substitute markov transition-weight


Recommended Posts

;;; little program to change markov-weight for a specific value
;;; to give markov a "rule-tendency" 

(setq transitions '((a (b 1) (c 3) (d 2) (e 1))
                    (b (a 2) (d 3))
                    (c (a 2) (e 1) (b 3))
                    (d (c 2) (b 1) (a 3))
                    (e (a 2) (b 2) (d 1))))


(defun substitute-transition-weight (transition-list value new-weight)
  (loop 
    for j in transition-list
    collect (append (list (first j))
                    (loop repeat (1- (length j))
                      for cnt = 1 then (incf cnt)
                      when (equal (first (nth cnt j)) value)
                      collect (list (first (nth cnt j)) new-weight)
                      else collect (nth cnt j)))))


(substitute-transition-weight transitions 'a 100)



;;; example for "concrete use"

(loop repeat 20
  with transitions = '((a (b 3) (c 3) (a 2))
                       (b (a 2) (b 3) (c 5))
                       (c (a 2) (c 1)))
  with weight = 1
  do (setq transitions (substitute-transition-weight transitions 'a weight))
  do (incf weight 2)
  collect (gen-markov-from-transitions transitions
	                             :size 20 :start 'a))

best wishes 

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