start of lispy forms for algorithmic-based data analysis (ala Breiman paper on stat...
[CommonLispStat.git] / src / algorithms / bootstrap.lisp
blob66c4b937a43a6bb9f7b92e42b1b758b040c3a894
1 ;;; -*- mode: lisp -*-
3 ;;; Time-stamp: <2009-01-23 13:18:30 tony>
4 ;;; Creation: <2008-03-11 19:18:34 user>
5 ;;; File: bootstrap.lisp
6 ;;; Author: AJ Rossini <blindglobe@gmail.com>
7 ;;; Copyright: (c)2009--, AJ Rossini. BSD, LLGPL, or GPLv2, depending
8 ;;; on how it arrives.
9 ;;; Purpose: bootstrapping algorithms for lispstat
11 ;;; What is this talk of 'release'? Klingons do not make software
12 ;;; 'releases'. Our software 'escapes', leaving a bloody trail of
13 ;;; designers and quality assurance people in its wake.
15 (in-package :cls-algorithms-bootstrap)
17 ;;; implememented through general macros for a lispy approach. There
18 ;;; could be a functional approach as well, i.e.
19 ;;; (bootstrap data #'function args)
20 ;;;
22 (defmacro with-data-bootstrap ((list-of-sources-and-var n) @body)
23 "A proposed lispy implementation, such as:
24 (with-data-bootstrap ((a dataset1)
25 (b dataset2))
26 (some-form-with-inputs a b c))
27 where there could be multiple datasets, with a and b, etc, being
28 bootstrap realizations of dataset1 and dataset2."
29 (Destructure list-of-sources-and-var)
30 (loop repeat n
31 (progn (pull-samples sources)
32 @body)
33 accumulate in result-list))
35 (defmacro with-correlated-data-bootstrap ())
37 (defgeneric bootstrap (data function args)
38 (:documentation "used such as: (bootstrap dataset t-test :significance 0.5)")
39 (:default-method (funcall #'function (bootstrap-sample data) (values args))))
45 2 possible paradigms:
47 (with-data-bootstrap ((a dataset1))
48 (t-test a :significance 0.05))
50 (bootstrap #'t-test a :significance 0.05)