(defmodel evett-model ((lamb (make-instance 'scale :label "LAMBDA" :from 1 :to 7 :foreground 'navy :master *MAIN-LABEL-FRAME* :orientation 'horizontal)) (n (make-instance 'scale :label "N" :from 1 :to 5 :foreground 'navy :master *MAIN-LABEL-FRAME* :orientation 'horizontal)) (f (make-instance 'scale :label "FValue" :from .01 :to .25 :master *MAIN-LABEL-FRAME* :orientation 'horizontal :resolution .01)) (lr (make-instance 'scale :label "LRCap" :master *MAIN-LABEL-FRAME* :from 50 :to 250 :resolution 25 :orientation 'horizontal)) (button (make-instance 'button :master *MODEL-LABEL-FRAME* :text "Generate" :command #'(lambda () (evett (value lamb) (value n) (value f) (value lr)))))) (setf (value f) .03) (setf (value lamb) 4) (setf (value n) 4) (setf (value lr) 200) (pack n :side :left) (pack lamb :side :left) (pack f :side :left) (pack lr :side :left) (pack button)) (defun evett (lamb n f lr) (let* ((p-values #(.25 .22 .14 .14 .069 .064 .033 .033 .022 .02 .013)) (s-values #(.728 .166 .065 .018 .018 .006)) (path (make-pathname :name "tmp.dat")) (str (open path :direction :output :if-exists :supersede))) (format str "#LAMBDA ~A N ~A LR~%" #\Tab #\Tab) (dotimes (x lamb) (dotimes (y n) (format str "~A ~A ~A ~A ~A~%" (+ 1 x) #\Tab (+ 1 y) #\Tab (min lr (+ (/ (* (elt p-values 0) (calculate-t (+ 1 x) (+ 2 y))) (* (elt p-values 1) (elt s-values (+ 1 y)) f)) (calculate-t (+ 1 x) 0)))))) (close str) (evett-plot (pathname-name path)))) (defun evett-plot (file) (with-gnuplot ('linux) (set-grid 'on) (format-gnuplot "set xticks 1") (format-gnuplot "set yticks 1") (format-gnuplot "set xlabel '~A'" "LAMBDA") (format-gnuplot "set ylabel '~A'" "N") (format-gnuplot "set zlabel '~A'" "LR") (format-gnuplot "set dgrid3d") (format-gnuplot "splot '~A' with linespoints" file))) (defun n! (n) (if (or (= n 0) (= n 1)) 1 (* n (n! (- n 1))))) (defun calculate-t (lamb j) (/ (* (exp (- lamb)) (expt lamb j)) (n! j)))