; use two sliders, to change the mean and standard deviation of ; a normal distribution whose density is graphed (def mean 0) (def sd 1) (def pl (plot-points '(-10 10) '(0 .4) :title "Normal Density")) (send pl :clear-points) (defun sqr(x) (* x x)) (defun ndens (x) (* (exp (* (sqr (/ (- x mean) sd)) -.5)) (/ 1 (* (sqrt (* 2 pi)) sd))) ) (defun doplot () (send pl :clear-lines :draw nil) (def llim (- mean (* sd 4))) (def ulim (+ mean (* sd 4))) (def xval (rseq llim ulim 100)) ; the mapcar function applies the named function (ndens) to each element ; in the xval list (send pl :add-lines xval (mapcar #'ndens xval)) ) ; produce the initial plot, with mean 0 and sd 1 (doplot) (defun change-mean(m) (def mean m) (doplot) ) (defun change-sd(s) (def sd (cond ((= s 0) sd) (t s))) (doplot) ) (def i1 (interval-slider-dialog (list -5 5) :points 40 :action 'change-mean :title "Mean" )) (send i1 :value 0) (def i2 (interval-slider-dialog (list .2 5) :points 19 :action 'change-sd :title "SD" )) (send i2 :value 1)