Changeset 34 for trunk/statistics
- Timestamp:
- 03/11/08 01:34:13 (8 months ago)
- Location:
- trunk/statistics
- Files:
-
- 6 modified
-
absolute-deviation.lisp (modified) (3 diffs)
-
autocorrelation.lisp (modified) (3 diffs)
-
covariance.lisp (modified) (3 diffs)
-
higher-moments.lisp (modified) (3 diffs)
-
mean-variance.lisp (modified) (24 diffs)
-
median-percentile.lisp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/statistics/absolute-deviation.lisp
r26 r34 1 1 ;; Absolute deviation 2 2 ;; Liam Healy, Sun Dec 31 2006 - 13:19 3 ;; Time-stamp: <2008-0 2-17 16:39:38EST absolute-deviation.lisp>3 ;; Time-stamp: <2008-03-09 19:21:48EDT absolute-deviation.lisp> 4 4 ;; $Id$ 5 5 … … 81 81 #| 82 82 (make-tests absolute-deviation 83 (letm ((vec (vector-double #(-3.21d0 1.0d0 12.8d0)))84 (weights (vector-double #(3.0d0 1.0d0 2.0d0))))83 (letm ((vec (vector-double-float #(-3.21d0 1.0d0 12.8d0))) 84 (weights (vector-double-float #(3.0d0 1.0d0 2.0d0)))) 85 85 (let ((mean (mean vec))) 86 86 (list … … 94 94 (LIST (LIST 6.18d0 6.647777777777779d0 6.18d0)) 95 95 (MULTIPLE-VALUE-LIST 96 (LETM ((VEC (VECTOR-DOUBLE #(-3.21d0 1.0d0 12.8d0)))97 (WEIGHTS (VECTOR-DOUBLE #(3.0d0 1.0d0 2.0d0))))96 (LETM ((VEC (VECTOR-DOUBLE-FLOAT #(-3.21d0 1.0d0 12.8d0))) 97 (WEIGHTS (VECTOR-DOUBLE-FLOAT #(3.0d0 1.0d0 2.0d0)))) 98 98 (LET ((MEAN (MEAN VEC))) 99 99 (LIST (ABSOLUTE-DEVIATION VEC) -
trunk/statistics/autocorrelation.lisp
r26 r34 1 1 ;; Autocorrelation 2 2 ;; Liam Healy, Sun Dec 31 2006 - 13:19 3 ;; Time-stamp: <2008-0 2-17 18:29:36EST autocorrelation.lisp>3 ;; Time-stamp: <2008-03-09 19:21:48EDT autocorrelation.lisp> 4 4 ;; $Id$ 5 5 … … 37 37 #| 38 38 (make-tests autocorrelation 39 (letm ((vec (vector-double #(-3.21d0 1.0d0 12.8d0))))39 (letm ((vec (vector-double-float #(-3.21d0 1.0d0 12.8d0)))) 40 40 (let ((mean (mean vec))) 41 41 (list … … 49 49 (LIST -0.04646366834251103d0 -0.04646366834251103d0)) 50 50 (MULTIPLE-VALUE-LIST 51 (LETM ((VEC (VECTOR-DOUBLE #(-3.21d0 1.0d0 12.8d0))))51 (LETM ((VEC (VECTOR-DOUBLE-FLOAT #(-3.21d0 1.0d0 12.8d0)))) 52 52 (LET ((MEAN (MEAN VEC))) 53 53 (LIST (AUTOCORRELATION VEC) -
trunk/statistics/covariance.lisp
r26 r34 1 1 ;; Covariance 2 2 ;; Liam Healy, Sun Dec 31 2006 - 13:19 3 ;; Time-stamp: <2008-0 2-17 16:48:17EST covariance.lisp>3 ;; Time-stamp: <2008-03-09 19:21:49EDT covariance.lisp> 4 4 ;; $Id$ 5 5 … … 39 39 #| 40 40 (make-tests covariance 41 (letm ((vec1 (vector-double #(-3.21d0 1.0d0 12.8d0)))42 (vec2 (vector-double #(1.15d0 -1.0d0 0.5d0))))41 (letm ((vec1 (vector-double-float #(-3.21d0 1.0d0 12.8d0))) 42 (vec2 (vector-double-float #(1.15d0 -1.0d0 0.5d0)))) 43 43 (let ((mean1 (mean vec1)) 44 44 (mean2 (mean vec2))) … … 54 54 (MULTIPLE-VALUE-LIST 55 55 (LETM 56 ((VEC1 (VECTOR-DOUBLE #(-3.21d0 1.0d0 12.8d0)))57 (VEC2 (VECTOR-DOUBLE #(1.15d0 -1.0d0 0.5d0))))56 ((VEC1 (VECTOR-DOUBLE-FLOAT #(-3.21d0 1.0d0 12.8d0))) 57 (VEC2 (VECTOR-DOUBLE-FLOAT #(1.15d0 -1.0d0 0.5d0)))) 58 58 (LET ((MEAN1 (MEAN VEC1)) (MEAN2 (MEAN VEC2))) 59 59 (LIST (COVARIANCE VEC1 VEC2) -
trunk/statistics/higher-moments.lisp
r26 r34 1 1 ;; Skewness and kurtosis. 2 2 ;; Liam Healy, Sun Dec 31 2006 - 14:20 3 ;; Time-stamp: <2008-0 2-17 16:42:59EST higher-moments.lisp>3 ;; Time-stamp: <2008-03-09 19:21:48EDT higher-moments.lisp> 4 4 ;; $Id$ 5 5 … … 121 121 #| 122 122 (make-tests higher-moments 123 (letm ((vec (vector-double #(-3.21d0 1.0d0 12.8d0))))123 (letm ((vec (vector-double-float #(-3.21d0 1.0d0 12.8d0)))) 124 124 (let* ((mean (mean vec)) 125 125 (sd (standard-deviation vec mean))) … … 137 137 -2.333333333333333d0 -2.333333333333333d0)) 138 138 (MULTIPLE-VALUE-LIST 139 (LETM ((VEC (VECTOR-DOUBLE #(-3.21d0 1.0d0 12.8d0))))139 (LETM ((VEC (VECTOR-DOUBLE-FLOAT #(-3.21d0 1.0d0 12.8d0)))) 140 140 (LET* ((MEAN (MEAN VEC)) 141 141 (SD (STANDARD-DEVIATION VEC MEAN))) -
trunk/statistics/mean-variance.lisp
r26 r34 1 1 ;; Mean, standard deviation, and variance 2 2 ;; Liam Healy, Sat Dec 2 2006 - 22:15 3 ;; Time-stamp: <2008-0 2-17 16:35:48EST mean-variance.lisp>3 ;; Time-stamp: <2008-03-09 19:21:47EDT mean-variance.lisp> 4 4 ;; $Id$ 5 5 … … 11 11 (defmacro defmfun-stats (&rest args) 12 12 "A defmfun for stats of double, single, and fixnum." 13 (defmfun-all 14 ;;'(double single fixnum long) 15 '(double single fixnum) 16 ;;'(:double :float :int :long-double) 17 '(:double :float :int) 18 "stats" 19 'gsl-vector 20 args)) 13 (defmfun-all 'vector '(double-float single-float fixnum) args "stats")) 21 14 22 15 (defmacro defmfun-stats-ds (&rest args) 23 16 "A defmfun for stats of double and single." 24 (defmfun-all 25 '(double single) 26 '(:double :float) 27 "stats" 28 'gsl-vector 29 args)) 17 (defmfun-all 'vector '(double-float single-float) args "stats")) 30 18 31 19 ;;;;**************************************************************************** … … 33 21 ;;;;**************************************************************************** 34 22 35 (defgeneric mean ( gsl-vector)23 (defgeneric mean (vector) 36 24 (:documentation ; FDL 37 25 "The arithmetic mean of the vector. … … 39 27 \Hat\mu and defined as \Hat\mu = (1/N) \sum x_i. Returns a double-float.")) 40 28 41 (defmfun-stats mean ((vector gsl-vector))29 (defmfun-stats mean ((vector vector)) 42 30 "gsl_stats_mean" 43 31 (((gsl-array vector) :pointer) (1 :int) ((dim0 vector) size)) 44 32 :c-return :double) 45 33 46 (defgeneric weighted-mean ( gsl-vector weights)34 (defgeneric weighted-mean (vector weights) 47 35 (:documentation ; FDL 48 36 "The weighted mean of the dataset, using the set of weights … … 50 38 \Hat\mu = (\sum w_i x_i) / (\sum w_i).")) 51 39 52 (defmfun-stats-ds weighted-mean ((vector gsl-vector) weights)40 (defmfun-stats-ds weighted-mean ((vector vector) weights) 53 41 "gsl_stats_wmean" 54 42 (((gsl-array weights) :pointer) (1 :int) … … 60 48 ;;;;**************************************************************************** 61 49 62 (defgeneric variance-nom ( gsl-vector)50 (defgeneric variance-nom (vector) 63 51 (:documentation ; FDL 64 52 "The estimated, or sample, variance of data. The … … 75 63 #'variance-m.")) 76 64 77 (defmfun-stats variance-nom ((vector gsl-vector))65 (defmfun-stats variance-nom ((vector vector)) 78 66 "gsl_stats_variance" 79 67 (((gsl-array vector) :pointer) (1 :int) ((dim0 vector) size)) … … 82 70 :c-return :double) 83 71 84 (defgeneric variance-m ( gsl-vector mean)72 (defgeneric variance-m (vector mean) 85 73 (:documentation ; FDL 86 74 "Compute the variance with the mean known to 87 75 avoid its recomputation.")) 88 76 89 (defmfun-stats variance-m ((vector gsl-vector) mean)77 (defmfun-stats variance-m ((vector vector) mean) 90 78 "gsl_stats_variance_m" 91 79 (((gsl-array vector) :pointer) (1 :int) … … 112 100 ;;;;**************************************************************************** 113 101 114 (defgeneric weighted-variance-nom ( gsl-vector weights)102 (defgeneric weighted-variance-nom (vector weights) 115 103 (:documentation ; FDL 116 104 "Compute the weighted variance with the mean unknown.")) 117 105 118 (defmfun-stats-ds weighted-variance-nom ((vector gsl-vector) weights)106 (defmfun-stats-ds weighted-variance-nom ((vector vector) weights) 119 107 "gsl_stats_wvariance" 120 108 (((gsl-array weights) :pointer) (1 :int) … … 124 112 :c-return :double) 125 113 126 (defgeneric weighted-variance-m ( gsl-vector weights mean)114 (defgeneric weighted-variance-m (vector weights mean) 127 115 (:documentation ; FDL 128 116 "Compute the weighted variance with the mean known to 129 117 avoid its recomputation.")) 130 118 131 (defmfun-stats-ds weighted-variance-m ((vector gsl-vector) weights mean)119 (defmfun-stats-ds weighted-variance-m ((vector vector) weights mean) 132 120 "gsl_stats_wvariance_m" 133 121 (((gsl-array weights) :pointer) (1 :int) … … 153 141 ;;;;**************************************************************************** 154 142 155 (defgeneric standard-deviation-nom ( gsl-vector)143 (defgeneric standard-deviation-nom (vector) 156 144 (:documentation ; FDL 157 145 "The standard deviation, square root of the variance.")) 158 146 159 (defmfun-stats standard-deviation-nom ((vector gsl-vector))147 (defmfun-stats standard-deviation-nom ((vector vector)) 160 148 "gsl_stats_sd" 161 149 (((gsl-array vector) :pointer) (1 :int) ((dim0 vector) size)) … … 164 152 :c-return :double) 165 153 166 (defgeneric standard-deviation-m ( gsl-vector mean)154 (defgeneric standard-deviation-m (vector mean) 167 155 (:documentation ; FDL 168 156 "The standard deviation with the mean known to 169 157 avoid its recomputation.")) 170 158 171 (defmfun-stats standard-deviation-m ((vector gsl-vector) mean)159 (defmfun-stats standard-deviation-m ((vector vector) mean) 172 160 "gsl_stats_sd_m" 173 161 (((gsl-array vector) :pointer) (1 :int) … … 185 173 ;;;;**************************************************************************** 186 174 187 (defgeneric weighted-standard-deviation-nom ( gsl-vector weights))175 (defgeneric weighted-standard-deviation-nom (vector weights)) 188 176 189 177 (defmfun-stats-ds weighted-standard-deviation-nom 190 ((vector gsl-vector) weights)178 ((vector vector) weights) 191 179 "gsl_stats_wsd" 192 180 (((gsl-array weights) :pointer) (1 :int) … … 196 184 :c-return :double) 197 185 198 (defgeneric weighted-standard-deviation-m ( gsl-vector weights mean))186 (defgeneric weighted-standard-deviation-m (vector weights mean)) 199 187 200 188 (defmfun-stats-ds weighted-standard-deviation-m 201 ((vector gsl-vector) weights mean)189 ((vector vector) weights mean) 202 190 "gsl_stats_wsd_m" 203 191 (((gsl-array weights) :pointer) (1 :int) … … 216 204 ;;;;**************************************************************************** 217 205 218 (defgeneric variance-with-fixed-mean ( gsl-vector mean)206 (defgeneric variance-with-fixed-mean (vector mean) 219 207 (:documentation ; FDL 220 208 "An unbiased estimate of the variance of … … 225 213 \Hat\sigma^2 = (1/N) \sum (x_i - \mu)^2.")) 226 214 227 (defmfun-stats variance-with-fixed-mean ((vector gsl-vector) mean)215 (defmfun-stats variance-with-fixed-mean ((vector vector) mean) 228 216 "gsl_stats_variance_with_fixed_mean" 229 217 (((gsl-array vector) :pointer) (1 :int) ((dim0 vector) size) … … 231 219 :c-return :double) 232 220 233 (defgeneric standard-deviation-with-fixed-mean ( gsl-vector mean)221 (defgeneric standard-deviation-with-fixed-mean (vector mean) 234 222 (:documentation ; FDL 235 223 "The standard deviation of data for a fixed population … … 238 226 239 227 (defmfun-stats standard-deviation-with-fixed-mean 240 ((vector gsl-vector) mean)228 ((vector vector) mean) 241 229 "gsl_stats_sd_with_fixed_mean" 242 230 (((gsl-array vector) :pointer) (1 :int) ((dim0 vector) size) … … 248 236 ;;;;**************************************************************************** 249 237 250 (defgeneric weighted-variance-with-fixed-mean ( gsl-vector weights mean)238 (defgeneric weighted-variance-with-fixed-mean (vector weights mean) 251 239 (:documentation ; FDL 252 240 "An unbiased estimate of the variance of weighted … … 258 246 259 247 (defmfun-stats-ds weighted-variance-with-fixed-mean 260 ((vector gsl-vector) weights mean)248 ((vector vector) weights mean) 261 249 "gsl_stats_wvariance_with_fixed_mean" 262 250 (((gsl-array weights) :pointer) (1 :int) … … 266 254 267 255 (defgeneric weighted-standard-deviation-with-fixed-mean 268 ( gsl-vector weights mean)256 (vector weights mean) 269 257 (:documentation ; FDL 270 258 "The square root of the corresponding variance … … 272 260 273 261 (defmfun-stats-ds weighted-standard-deviation-with-fixed-mean 274 ((vector gsl-vector) weights mean)262 ((vector vector) weights mean) 275 263 "gsl_stats_wsd_with_fixed_mean" 276 264 (((gsl-array weights) :pointer) (1 :int) … … 285 273 #| 286 274 (make-tests mean-variance 287 (letm ((vec (vector-double #(-3.21d0 1.0d0 12.8d0)))288 (weights (vector-double #(3.0d0 1.0d0 2.0d0))))275 (letm ((vec (vector-double-float #(-3.21d0 1.0d0 12.8d0))) 276 (weights (vector-double-float #(3.0d0 1.0d0 2.0d0)))) 289 277 (let ((mean (mean vec)) 290 278 (wmean (weighted-mean vec weights))) … … 321 309 (MULTIPLE-VALUE-LIST 322 310 (LETM 323 ((VEC (VECTOR-DOUBLE #(-3.21d0 1.0d0 12.8d0)))324 (WEIGHTS (VECTOR-DOUBLE #(3.0d0 1.0d0 2.0d0))))311 ((VEC (VECTOR-DOUBLE-FLOAT #(-3.21d0 1.0d0 12.8d0))) 312 (WEIGHTS (VECTOR-DOUBLE-FLOAT #(3.0d0 1.0d0 2.0d0)))) 325 313 (LET ((MEAN (MEAN VEC)) 326 314 (WMEAN (WEIGHTED-MEAN VEC WEIGHTS))) -
trunk/statistics/median-percentile.lisp
r26 r34 1 1 ;; Median and percentile 2 2 ;; Liam Healy, Sun Dec 31 2006 - 13:19 3 ;; Time-stamp: <2008-0 2-17 16:50:24EST median-percentile.lisp>3 ;; Time-stamp: <2008-03-09 19:19:28EDT median-percentile.lisp> 4 4 ;; $Id$ 5 5 … … 31 31 :c-return :double 32 32 :documentation ; FDL 33 "A quantile value of sorted-data, gsl-vector-double. The33 "A quantile value of sorted-data, vector-double-float. The 34 34 elements of the array must be in ascending numerical order. The 35 35 quantile is determined by a fraction between 0 and 1. For … … 51 51 #| 52 52 (make-tests median-percentile 53 (letm ((vec (vector-double #(-3.21d0 1.0d0 12.8d0))))53 (letm ((vec (vector-double-float #(-3.21d0 1.0d0 12.8d0)))) 54 54 (median vec)) 55 (letm ((vec (vector-double #(-18.0d0 -12.0d0 -3.21d0 0.5d0 1.0d0 2.7d0 12.8d0)))) 55 (letm ((vec (vector-double-float 56 #(-18.0d0 -12.0d0 -3.21d0 0.5d0 1.0d0 2.7d0 12.8d0)))) 56 57 (quantile vec 0.75d0))) 57 58 |# … … 61 62 (LIST 1.0d0) 62 63 (MULTIPLE-VALUE-LIST 63 (LETM ((VEC (VECTOR-DOUBLE #(-3.21d0 1.0d0 12.8d0))))64 (LETM ((VEC (VECTOR-DOUBLE-FLOAT #(-3.21d0 1.0d0 12.8d0)))) 64 65 (MEDIAN VEC)))) 65 66 (LISP-UNIT::ASSERT-NUMERICAL-EQUAL 66 67 (LIST 1.85d0) 67 68 (MULTIPLE-VALUE-LIST 68 (LETM ((VEC (VECTOR-DOUBLE #(-18.0d0 -12.0d0 -3.21d0 0.5d0 1.0d0 2.7d0 12.8d0)))) 69 (LETM ((VEC (VECTOR-DOUBLE-FLOAT 70 #(-18.0d0 -12.0d0 -3.21d0 0.5d0 1.0d0 2.7d0 12.8d0)))) 69 71 (QUANTILE VEC 0.75d0))))) 70 72
