make-datatable-from-listoflists function.
[CommonLispStat.git] / src / algorithms / bootstrap.lisp
blobf6e21be5c38b80c8e3f6d41ff757e5259a57b261
1 ;;; -*- mode: lisp -*-
3 ;;; Time-stamp: <2009-02-06 16:06:02 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 ;;; functional
39 (defgeneric bootstrap-sample (data &optional n replace)
40 (:documentation "generate a dataset of N obs from DATA either with
41 or without replace(ment)")
42 (:default-method (data &optional n replace)))
44 (defgeneric bootstrap (data function args)
45 (:documentation "used such as: (bootstrap dataset t-test :significance 0.5)")
46 (:default-method (funcall #'function (bootstrap-sample data) (values args))))
50 2 possible paradigms:
52 (with-data-bootstrap ((a dataset1))
53 (t-test a :significance 0.05))
55 (bootstrap #'t-test a :significance 0.05)