(defmodel evett-model (with-main-frame ((lamb (make-hscale "LAMBDA" 1 7)) (n (make-hscale "N" 1 5)) (f (make-hscale "FValue" .01 .25 .01)) (lr (make-hscale "LRCAP" 50 250 25))))) (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)))) (defmacro gnuplot-setup (&body body) `(with-gnuplot ('linux) (format-gnuplot "reset") ,@body)) (defun evett-plot (file) (gnuplot-setup (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") (make-images 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))) (defmacro make-awesome-plot (filename x y dx dy) `(progn (format-gnuplot "set size .6,.6") (format-gnuplot (format nil "set view ~A,~A" x y)) (format-gnuplot "set output \"0.gif\"") (format-gnuplot (format nil "splot '~a' with linespoints" filename)) (format-gnuplot (format nil "set view ~A,~A" (+ x dx) (+ y dy))) (format-gnuplot "set output \"1.gif\"") (format-gnuplot (format nil "splot '~a' with linespoints" filename)) (format-gnuplot (format nil "set view ~A,~A" (+ x (* 2 dx)) (+ y (* 2 dy)))) (format-gnuplot "set output \"2.gif\"") (format-gnuplot (format nil "splot '~a' with linespoints" filename)))) (defun make-images (filename &optional (title "Data Images") (xlabel "LAMBDA") (ylabel "N") (zlabel "LR")) (with-ltk () (let* ((canvas (make-instance 'canvas)) (image0 (make-image)) (image1 (make-image)) (image2 (make-image))) (gnuplot-setup (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 "set terminal gif") (format-gnuplot "set size .6,.6") (make-awesome-plot filename 45 45 45 0)) (image-load image0 "0.gif") (image-load image1 "1.gif") (image-load image2 "2.gif") (create-image canvas 0 0 :image image0) (create-image canvas 0 289 :image image1) (create-image canvas 0 578 :image image2) (configure canvas :width 384) (configure canvas :height 865) (pack canvas))))