; http://geocities.com/n8chz/dom.txt ; Use of this file is ungovernmed by the Cypherpunks Anti-License. ; Do with it as you will. ; These experiments deal with the concept of plotting efficient frontiers ; for numerically-tabulated data sets. ; Another computational issue dealt with in this file is the quantile ; ranking of individual parameter values among data points that happen to ; meet the criterion of nondomination. ; Kitchen tested under ; Gnu Common Lisp ; version 2-2.2000000000000002 ; random list of numbers of length len and upper bound modd-1 (defun random-lon (len modd) (if (zerop len) nil (cons (random modd) (random-lon (1- len) modd)))) ; random list of lists ; the number of points is the number of lists ; the number of params is the length of each list (defun random-lol (params points modd) (if (zerop points) nil (cons (random-lon params modd) (random-lol params (1- points) modd)))) ; Does list1 dominate list2? ; list1 and list2 are lists of numbers of equal length ; each position within the list represents a parameter ; each list represents a data point (defun domp (list1 list2) (and (eval (cons 'or (mapcar #'> list1 list2))) (eval (cons 'and (mapcar #'>= list1 list2))))) ; nondominated subset of lol ; lol is a list of lists of numbers of equal length ; This works. (defun nondom (lol) (do* ((indx lol (cdr indx)) (rv lol (remove-if #'(lambda (x) (domp (car indx) x)) rv))) ((null indx) rv))) (defun transpose (lol) (if (and lol (car lol)) (cons (mapcar #'car lol) (transpose (mapcar #'cdr lol))))) ; Look up: ; Dr. Gordon Neufeld, neo-authoritarian theorist of child behavior (defun tcount (s) (if s (+ (if (car s) 1 0) (tcount (cdr s))) 0)) ; quantile ranking of number n in list of numbers n ; using midpoint rule ; in case of multiples, the midpoint of the multiples' rankings is used (defun quantile-in (n lon) (/ (+ (tcount (mapcar #'(lambda (x) (> n x)) lon)) (tcount (mapcar #'(lambda (x) (>= n x)) lon))) (* (length lon) 2))) ; assign quantile rank to each element ; utilizes #'tcount and #'quantile-in, above ; This works. (defun quantile-rank (lon) (mapcar #'cons lon (mapcar #'(lambda (x) (quantile-in x lon)) lon))) ; Check out the following: ; disembodied thought ; reductive materialism ; triaxial cartesian space ; list nondominated subset of lol ; cons each value to the quantile ranking for its parameter ; within the nondominated subset (defun normalize (lol) (transpose (mapcar #'quantile-rank (transpose (nondom lol)))))