|
Revision 34, 1.4 kB
(checked in by lhealy, 9 months ago)
|
|
The classes/types in the different contexts are now gathered together
in one place, in *type-names* for the types and in *data-class-name*
for data classes, populated by #'add-data-class. Both defdata and
defmfun-all use the table and so mapping between various names is
consistent. The data class names are now different, *-double-float
and *-single-float replaces *-double and *-single. The regression
tests give the same results as before.
|
-
Property svn:keywords set to
Id
|
| Line | |
|---|
| 1 | ;; Autocorrelation |
|---|
| 2 | ;; Liam Healy, Sun Dec 31 2006 - 13:19 |
|---|
| 3 | ;; Time-stamp: <2008-03-09 19:21:48EDT autocorrelation.lisp> |
|---|
| 4 | ;; $Id$ |
|---|
| 5 | |
|---|
| 6 | (in-package :gsl) |
|---|
| 7 | |
|---|
| 8 | ;;; To do: stride other than 1 when that information is availble from |
|---|
| 9 | ;;; the vector. |
|---|
| 10 | |
|---|
| 11 | (defmfun autocorrelation-nom (data) |
|---|
| 12 | "gsl_stats_lag1_autocorrelation" |
|---|
| 13 | (((gsl-array data) :pointer) (1 :int) ((dim0 data) size)) |
|---|
| 14 | :c-return :double |
|---|
| 15 | :index autocorrelation |
|---|
| 16 | :export nil) |
|---|
| 17 | |
|---|
| 18 | (defmfun autocorrelation-m (data mean) |
|---|
| 19 | "gsl_stats_lag1_autocorrelation_m" |
|---|
| 20 | (((gsl-array data) :pointer) (1 :int) |
|---|
| 21 | ((dim0 data) size) (mean :double)) |
|---|
| 22 | :c-return :double |
|---|
| 23 | :index autocorrelation |
|---|
| 24 | :export nil) |
|---|
| 25 | |
|---|
| 26 | (export 'autocorrelation) |
|---|
| 27 | (defun-optionals autocorrelation (data &optional mean) |
|---|
| 28 | -nom -m |
|---|
| 29 | ;; FDL |
|---|
| 30 | "The lag-1 autocorrelation of the dataset data. |
|---|
| 31 | a_1 = {\sum_{i = 1}^{n} (x_{i} - \Hat\mu) (x_{i-1} - \Hat\mu) |
|---|
| 32 | \over |
|---|
| 33 | \sum_{i = 1}^{n} (x_{i} - \Hat\mu) (x_{i} - \Hat\mu)}.") |
|---|
| 34 | |
|---|
| 35 | ;;; Examples and unit test |
|---|
| 36 | |
|---|
| 37 | #| |
|---|
| 38 | (make-tests autocorrelation |
|---|
| 39 | (letm ((vec (vector-double-float #(-3.21d0 1.0d0 12.8d0)))) |
|---|
| 40 | (let ((mean (mean vec))) |
|---|
| 41 | (list |
|---|
| 42 | (autocorrelation vec) |
|---|
| 43 | (autocorrelation vec mean))))) |
|---|
| 44 | |# |
|---|
| 45 | |
|---|
| 46 | (LISP-UNIT:DEFINE-TEST AUTOCORRELATION |
|---|
| 47 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 48 | (LIST |
|---|
| 49 | (LIST -0.04646366834251103d0 -0.04646366834251103d0)) |
|---|
| 50 | (MULTIPLE-VALUE-LIST |
|---|
| 51 | (LETM ((VEC (VECTOR-DOUBLE-FLOAT #(-3.21d0 1.0d0 12.8d0)))) |
|---|
| 52 | (LET ((MEAN (MEAN VEC))) |
|---|
| 53 | (LIST (AUTOCORRELATION VEC) |
|---|
| 54 | (AUTOCORRELATION VEC MEAN))))))) |
|---|