You are looking at historical revision 20488 of this page. It may differ significantly from its current revision.

Still under testing!

## Introduction

This library is a port of Larry Hunter's Lisp statistics library to chicken scheme.

The library provides a number of formulae and methods taken from the book "Fundamentals of Biostatistics" by Bernard Rosner (5th edition).

## Provided Functions

### Utilities

• average-rank
• beta-incomplete
• bin-and-count
• combinations
• factorial
• find-critical-value
• fisher-z-transform
• gamma-incomplete
• gamma-ln
• permutations
• random-normal
(random-pick items)
given a list of items, returns a random item.
(random-sample n items)
given a number of items to select, n, and a list of items to select from, items, returns a random sample without replacement of size n.
(sign n)
given a number n, returns 0, 1 or -1 according to if n is zero, positive or negative.
(square n)
given a number n, returns the square of n.

### Descriptive statistics

These functions provide information on a given list of numbers. Note, the list of items does not have to be sorted.

(mean items)
given a list of numbers, items, returns the arithmetic mean of the items (the sum of the numbers divided by the number of numbers).
`(mean '(1 2 3 4 5)) => 3`
(median items)
given a list of numbers, items, returns the value which separates the upper and lower halves of the list of numbers.
`(median '(1 2 3 4)) => 5/2`
(mode items)
(geometric-mean items)
given a list of numbers, items, returns the geometric mean of the items (the result of multiplying the items together and then taking the nth root, where n is the number of items).
`(geometric-mean '(1 2 3 4 5)) => 2.60517108469735`
(range items)
given a list of numbers, items, returns the difference between the biggest and the smallest value.
`(range '(5 1 2 3 4)) => 4`
(percentile items percent)
given a list of numbers, items, and a percentage, percent, returns the item closest to the percent value if the items are sorted into order; the returned item may be in the list, or the average of adjacent values.
```(percentile '(1 2 3 4) 50) => 5/2
(percentile '(1 2 3 4) 67) => 3```
(variance items)
given a list of numbers, items, returns the variance of the numbers.
(standard-deviation items)
given a list of numbers, items, returns the standard deviation of the numbers.
(coefficient-of-variation items)
given a list of numbers, items, returns 100 * (std-dev / mean) of the items.
`(coefficient-of-variation '(1 2 3 4)) => 51.6397779494322`
(standard-error-of-the-mean items)
given a list of numbers, items, returns std-dev / sqrt(length items).
` (standard-error-of-the-mean '(1 2 3 4)) => 0.645497224367903`
(mean-sd-n items)
given a list of numbers, items, returns three values, one for the mean, one for the standard deviation, and one for the length of the list.
```> (mean-sd-n '(1 2 3 4))
5/2
1.29099444873581
4```

### Distributional functions

• binomial-probability
• binomial-cumulative-probability
• binomial-ge-probability
• binomial-le-probability
• poisson-probability
• poisson-cumulative-probability
• poisson-ge-probability
• normal-pdf
• convert-to-standard-normal
• phi
• z
• t-distribution
• chi-square
• chi-square-cdf

### Confidence intervals

• binomial-probability-ci
• poisson-mu-ci
• normal-mean-ci
• normal-mean-ci-on-sequence
• normal-variance-ci
• normal-variance-ci-on-sequence
• normal-sd-ci
• normal-sd-ci-on-sequence

### Hypothesis testing

#### (parametric)

• z-test
• z-test-on-sequence
• t-test-one-sample
• t-test-one-sample-on-sequence
• t-test-paired
• t-test-paired-on-sequences
• t-test-two-sample
• t-test-two-sample-on-sequences
• f-test
• chi-square-test-one-sample
• binomial-test-one-sample
• binomial-test-two-sample
• fisher-exact-test
• mcnemars-test
• poisson-test-one-sample

#### (non parametric)

• sign-test
• sign-test-on-sequence
• wilcoxon-signed-rank-test
• wilcoxon-signed-rank-test-on-sequences
• chi-square-test-rxc
• chi-square-test-for-trend

### Sample size estimates

• t-test-one-sample-sse
• t-test-two-sample-sse
• t-test-paired-sse
• binomial-test-one-sample-sse
• binomial-test-two-sample-sse
• binomial-test-paired-sse
• correlation-sse

### Correlation and regression

• linear-regression
• correlation-coefficient
• correlation-test-two-sample
• correlation-test-two-sample-on-sequences
• spearman-rank-correlation

### Significance test functions

• t-significance
• f-significance

## Authors

Peter Lane wrote the scheme version of this library. The original Lisp version was written by Larry Hunter.