autocorrelation.lisp 1.76 KB
 liam committed Feb 04, 2008 1 2 ;; Autocorrelation ;; Liam Healy, Sun Dec 31 2006 - 13:19  Liam M. Healy committed Jan 13, 2012 3 ;; Time-stamp: <2012-01-13 12:01:14EST autocorrelation.lisp>  Liam Healy committed Dec 27, 2009 4 ;;  Liam M. Healy committed Jan 10, 2011 5 ;; Copyright 2006, 2007, 2008, 2009, 2011 Liam M. Healy  Liam Healy committed Dec 27, 2009 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ;; Distributed under the terms of the GNU General Public License ;; ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see .  liam committed Jan 01, 2007 20 21 22 23 24 25  (in-package :gsl) ;;; To do: stride other than 1 when that information is availble from ;;; the vector.  Liam Healy committed Aug 20, 2008 26 27 28 (defmfun autocorrelation ((data vector) &optional mean) (("gsl_stats" :type "_lag1_autocorrelation") ("gsl_stats" :type "_lag1_autocorrelation_m"))  Liam M. Healy committed Jan 13, 2012 29 30  ((((grid:foreign-pointer data) :pointer) (1 :int) ((dim0 data) :sizet)) (((grid:foreign-pointer data) :pointer) (1 :int) ((dim0 data) :sizet)  Liam Healy committed Aug 20, 2008 31 32 33  (mean :double))) :definition :generic :element-types :no-complex  liam committed Jan 01, 2007 34  :c-return :double  Liam Healy committed Dec 07, 2008 35  :inputs (data)  Liam Healy committed Aug 20, 2008 36  :documentation ; FDL  liam committed Feb 18, 2008 37  "The lag-1 autocorrelation of the dataset data.  liam committed Jan 01, 2007 38 39 40 41  a_1 = {\sum_{i = 1}^{n} (x_{i} - \Hat\mu) (x_{i-1} - \Hat\mu) \over \sum_{i = 1}^{n} (x_{i} - \Hat\mu) (x_{i} - \Hat\mu)}.")  liam committed Feb 18, 2008 42 43 ;;; Examples and unit test  Liam Healy committed Oct 25, 2008 44 (save-test autocorrelation  Liam Healy committed Dec 26, 2008 45  (let ((vec #m(-3.21d0 1.0d0 12.8d0)))  liam committed Feb 04, 2008 46  (let ((mean (mean vec)))  liam committed Jan 01, 2007 47 48  (list (autocorrelation vec)  liam committed Feb 18, 2008 49  (autocorrelation vec mean)))))