From d610448b3d82f54836105684507e5c84232dc9c5 Mon Sep 17 00:00:00 2001 From: AJ Rossini Date: Fri, 2 Nov 2007 08:51:23 +0100 Subject: [PATCH] Move split-list to compound. Make plot-points a dummy until we have graphics. --- compound.lsp | 55 +++++++++++++++++++++++++++++++++++++------------------ data.lisp | 44 +++----------------------------------------- regression.lsp | 23 ++++++++++++++--------- 3 files changed, 54 insertions(+), 68 deletions(-) diff --git a/compound.lsp b/compound.lsp index 667e291..b8a876e 100644 --- a/compound.lsp +++ b/compound.lsp @@ -26,28 +26,14 @@ (:export compound-data-p *compound-data-proto* compound-object-p compound-data-seq compound-data-length - element-list element-seq - sort-data order rank - - recursive-map-elements map-elements - - repeat - ;; export matrix-related functionality (not sure??) - + recursive-map-elements map-elements repeat check-sequence get-next-element make-next-element set-next-element - sequencep iseq - - ;; maybe? - ordered-nneg-seq - select - - which - ;; vector differences - difference rseq - )) + sequencep iseq ordered-nneg-seq + select split-list which + difference rseq)) (in-package :lisp-stat-compound-data) @@ -661,3 +647,36 @@ Returns a list of NUM equally spaced points starting at A and ending at B." (+ a (* (values-list (iseq 0 (1- num))) (/ (float (- b a)) (1- num))))) + +(defun split-list (x n) +"Args: (list cols) +Returns a list of COLS lists of equal length of the elements of LIST. +Example: (split-list '(1 2 3 4 5 6) 2) returns ((1 2 3) (4 5 6))" + (check-one-fixnum n) + (if (/= (rem (length x) n) 0) (error "length not divisible by ~a" n)) + (flet ((next-split () + (let ((result nil) + (end nil)) + (dotimes (i n result) + (declare (fixnum i)) + (let ((c-elem (list (first x)))) + (cond ((null result) + (setf result c-elem) + (setf end result)) + (t + (setf (rest end) c-elem) + (setf end (rest end))))) + (setf x (rest x)))))) + (let ((result nil) + (end nil) + (k (/ (length x) n))) + (declare (fixnum k)) + (dotimes (i k result) + (declare (fixnum i)) + (let ((c-sub (list (next-split)))) + (cond ((null result) + (setf result c-sub) + (setf end result)) + (t + (setf (rest end) c-sub) + (setf end (rest end))))))))) diff --git a/data.lisp b/data.lisp index 7962d53..ad5e194 100644 --- a/data.lisp +++ b/data.lisp @@ -39,11 +39,9 @@ :lisp-stat-linalg) (:shadowing-import-from :lisp-stat-object-system slot-value call-method call-next-method) - (:export - ;;; from statistics.lsp - open-file-dialog read-data-file read-data-columns load-data - load-example *variables* *ask-on-redefine* def variables savevar - undef split-list )) + (:export open-file-dialog read-data-file read-data-columns load-data + load-example *variables* *ask-on-redefine* + def variables savevar undef)) (in-package :lisp-stat-data) @@ -285,39 +283,3 @@ names each is unbound and removed. Returns V." (makunbound s))) v) -;;;; -;;;; Miscellaneous Routines -;;;; - -(defun split-list (x n) -"Args: (list cols) -Returns a list of COLS lists of equal length of the elements of LIST. -Example: (split-list '(1 2 3 4 5 6) 2) returns ((1 2 3) (4 5 6))" - (check-one-fixnum n) - (if (/= (rem (length x) n) 0) (error "length not divisible by ~a" n)) - (flet ((next-split () - (let ((result nil) - (end nil)) - (dotimes (i n result) - (declare (fixnum i)) - (let ((c-elem (list (first x)))) - (cond ((null result) - (setf result c-elem) - (setf end result)) - (t - (setf (rest end) c-elem) - (setf end (rest end))))) - (setf x (rest x)))))) - (let ((result nil) - (end nil) - (k (/ (length x) n))) - (declare (fixnum k)) - (dotimes (i k result) - (declare (fixnum i)) - (let ((c-sub (list (next-split)))) - (cond ((null result) - (setf result c-sub) - (setf end result)) - (t - (setf (rest end) c-sub) - (setf end (rest end))))))))) diff --git a/regression.lsp b/regression.lsp index 69924bc..3a8a8c2 100644 --- a/regression.lsp +++ b/regression.lsp @@ -425,16 +425,21 @@ Computes Cook's distances." (send self :num-coefs)))) (if-else (send self :included) (* res (/ lev (- 1 lev) )) (* res lev)))) + +(defun plot-points (x y) + "FIXME!!" + (error "Graphics not implemented yet.") + ;; Can not plot points yet!! -;;(defmeth regression-model-proto :plot-residuals (&optional x-values) -;;"Message args: (&optional x-values) -;;Opens a window with a plot of the residuals. If X-VALUES are not supplied -;;the fitted values are used. The plot can be linked to other plots with the -;;link-views function. Returns a plot object." -;; (plot-points (if x-values x-values (send self :fit-values)) -;; (send self :residuals) -;; :title "Residual Plot" -;; :point-labels (send self :case-labels))) +(defmeth regression-model-proto :plot-residuals (&optional x-values) +"Message args: (&optional x-values) +Opens a window with a plot of the residuals. If X-VALUES are not supplied +the fitted values are used. The plot can be linked to other plots with the +link-views function. Returns a plot object." + (plot-points (if x-values x-values (send self :fit-values)) + (send self :residuals) + :title "Residual Plot" + :point-labels (send self :case-labels))) (defmeth regression-model-proto :plot-bayes-residuals (&optional x-values) -- 2.11.4.GIT