asb: head /dev/brain > /dev/www

My home, musings, and wanderings on the world wide web.

The modern paradigm for hypothesis testing

In a couple of earlier posts, I briefly summarized the Fisherian and the Neyman-Pearson (NP) approaches to frequentist hypothesis testing. In this post, I outline the modern paradigm of hypothesis testing taught in a graduate social science course and the various ways in which it is, if not wrong, misguided and prone to misinterpretation.

Note to self: Origins of 'car' and 'cdr'

So, I am rereading the book Gentle Introduction to Symbolic Computing by Touretzky. I highly recommend the book to people who are new to both lisp and programming. Today’s post is simply a quote from the book that I want to preserve as a note to self on the origins of the two fundamental lisp functions: car and cdr.

These names are relics from the early days of computing, when Lisp first ran on a machine called the IBM 704. The 704 was so primitive it didn't even have transistors -- it used vacuum tubes. Each of its 'registers' was divided into several components, two of which were the address portion and the decrement portion. Back then, the name CAR stood for Contents of Address portion of Register, and CDR stood for Contents of Decrement portion of Register.

99 LISP problems: Problem #28

Solution to the 99 LISP Problems #28

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
;;; Part a)
(defun lsort (alist)
  (sort
    alist
    #'<
    :key #'length))

;;; Part b)
(defun count-elem (alist elem)
  (apply
    #'+
    (mapcar
      (lambda (x)
        (if (equalp x elem) 1 0))
      alist)))

(defun lfsort (alist)
  (let ((lengths (mapcar #'length alist)))
    (sort
      alist #'<
      :key (lambda (x) (count-elem lengths (length x))))))

Lisp dialect: Steel Bank Common Lisp

99 LISP problems: Problem #25

Solution to the 99 LISP Problems #25

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
(defun element-at (alist n)
  (if (< (length alist) n)
    nil
    (if (= n 1)
      (car alist)
      (element-at (cdr alist) (1- n)))))

(defun remove-at (alist n)
  (let ((i 1))
    (mapcan
      (lambda (x)
        (let ((j i))
          (setf i (1+ i))
          (if (= j n) nil (list x))))
      alist)))

(defun rnd-select (alist n)
  (if (<= n 0)
    nil
    (let ((k (1+ (random (length alist)))))
      (append
        (list (element-at alist k))
        (rnd-select (remove-at alist k) (1- n))))))

(defun rnd-permu (alist)
  (rnd-select alist (length alist)))

Lisp dialect: Steel Bank Common Lisp

99 LISP problems: Problem #24

Solution to the 99 LISP Problems #24

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
(defun element-at (alist n)
  (if (< (length alist) n)
    nil
    (if (= n 1)
      (car alist)
      (element-at (cdr alist) (1- n)))))

(defun remove-at (alist n)
  (let ((i 1))
    (mapcan
      (lambda (x)
        (let ((j i))
          (setf i (1+ i))
          (if (= j n) nil (list x))))
      alist)))

(defun rnd-select (alist n)
  (if (<= n 0)
    nil
    (let ((k (1+ (random (length alist)))))
      (append
        (list (element-at alist k))
        (rnd-select (remove-at alist k) (1- n))))))

(defun lotto-select (n m)
  (if (< m n)
    nil
    (rnd-select (range 1 m) n)))

Lisp dialect: Steel Bank Common Lisp