Skip to content

Commit

Permalink
chi-square-p-value
Browse files Browse the repository at this point in the history
  • Loading branch information
jaor committed Aug 25, 2016
1 parent 7bc9be3 commit 97b49e4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
11 changes: 10 additions & 1 deletion quick-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ Items:
(equal-to-items? <field-designator> <item0> ... <itemn>)
```

Clustering:

```
(row-distance <list-of-field-values> [<list-of-field-values> <weights>])
(row-distance-squared <list-of-field-values> [<list-of-field-values> <weights>])
```

## Strings and regular expressions

Conversion of any value to a string:
Expand Down Expand Up @@ -163,7 +170,8 @@ Mathematical functions:
(exp <x>) ;; Exponential
(floor <x>)
(ln <x>) ;; Natural logarithm
(log <x>) ;; Base-2 logarithm
(log <x>) ;; Natural logarithm
(log2 <x>) ;; Base-2 logarithm
(log10 <x>) ;; Base-10 logarithm
(max <x0> ... <xn>)
(min <x0> ... <xn>)
Expand All @@ -182,6 +190,7 @@ Mathematical functions:
(to-degrees <x>) ;; <x> := radians
(to-radians <x>) ;; <x> := degrees
(linear-regression <x1> <y1> ... <xn> <yn>) ;; slope, intercept, pearson
(chi-square-p-value <degrees of freedom> <value>)
```
## Coercions
Expand Down
27 changes: 26 additions & 1 deletion user-manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ missing value.

We provide a host of mathematical functions:

````
```
(max <x0> ... <xn>)
(min <x0> ... <xn>)
Expand Down Expand Up @@ -851,6 +851,8 @@ Currently there's no way of specifying the seed used for random number
generation, but it's coming shortly to a selected data generation
language very near to you.

### Regression

It's also possible to compute the slope, intercept and Pearson
coeffient of the linear regression of a set of points given as a list
of alternating x and y coordinates:
Expand All @@ -867,6 +869,29 @@ e.g.
(linear-regression 2.0 3.1 2.3 3.3 24.3 45.2) => (1.89 -0.87 0.9999)
```

### Statistical functions

The function `chi-square-p-value` computes the p-value of a Chi-square
distribution with the given number of degrees of freedom and a given
cut value:

```
(chi-square-p-value <d> <x>)
;; => <p-value>, with <d> integer <x> a number
```

Thus, the value `x` passes the Chi-square test if the value returned
by `(chi-square-p-value d x)` is less than or equal to `x`. For
instance, the expression:

```
(<= (chi-square-p-value 2 (field "000000")) 0.05)
```

will compute a boolean that tells you whether the field "000000"
passes a Chi-square test for two degrees of freedom with significance
level 0.05.

## Dates and times

### Epoch fields
Expand Down

0 comments on commit 97b49e4

Please sign in to comment.