| 1 | ;; Error functions |
|---|
| 2 | ;; Liam Healy, Mon Mar 20 2006 - 22:31 |
|---|
| 3 | ;; Time-stamp: <2008-02-16 20:54:49EST error-functions.lisp> |
|---|
| 4 | ;; $Id$ |
|---|
| 5 | |
|---|
| 6 | (in-package :gsl) |
|---|
| 7 | |
|---|
| 8 | (defmfun erf (x) |
|---|
| 9 | "gsl_sf_erf_e" ((x :double) (ret sf-result)) |
|---|
| 10 | :documentation ; FDL |
|---|
| 11 | "The error function erf(x), where |
|---|
| 12 | erf(x) = (2/\sqrt(\pi)) \int_0^x dt \exp(-t^2).") |
|---|
| 13 | |
|---|
| 14 | (defmfun erfc (x) |
|---|
| 15 | "gsl_sf_erfc_e" ((x :double) (ret sf-result)) |
|---|
| 16 | :documentation ; FDL |
|---|
| 17 | "The complementary error function |
|---|
| 18 | erfc(x) = 1 - erf(x) = (2/\sqrt(\pi)) \int_x^\infty \exp(-t^2).") |
|---|
| 19 | |
|---|
| 20 | (defmfun log-erfc (x) |
|---|
| 21 | "gsl_sf_log_erfc_e" ((x :double) (ret sf-result)) |
|---|
| 22 | :documentation ; FDL |
|---|
| 23 | "The logarithm of the complementary error function \log(\erfc(x)).") |
|---|
| 24 | |
|---|
| 25 | (defmfun erf-Z (x) |
|---|
| 26 | "gsl_sf_erf_Z_e" ((x :double) (ret sf-result)) |
|---|
| 27 | :documentation ; FDL |
|---|
| 28 | "The Gaussian probability density function |
|---|
| 29 | Z(x) = (1/sqrt{2\pi}) \exp(-x^2/2)}.") |
|---|
| 30 | |
|---|
| 31 | (defmfun erf-Q (x) |
|---|
| 32 | "gsl_sf_erf_Q_e" ((x :double) (ret sf-result)) |
|---|
| 33 | :documentation ; FDL |
|---|
| 34 | "The upper tail of the Gaussian probability function |
|---|
| 35 | Q(x) = (1/\sqrt{2\pi}) \int_x^\infty dt \exp(-t^2/2)}.") |
|---|
| 36 | |
|---|
| 37 | (defmfun hazard (x) |
|---|
| 38 | "gsl_sf_hazard_e" ((x :double) (ret sf-result)) |
|---|
| 39 | :documentation ; FDL |
|---|
| 40 | "The hazard function for the normal distribution.") |
|---|
| 41 | |
|---|
| 42 | #| |
|---|
| 43 | (make-tests error-functions |
|---|
| 44 | (erf 1.0d0) |
|---|
| 45 | (erfc 1.0d0) |
|---|
| 46 | (log-erfc 1.0d0) |
|---|
| 47 | (erf-z 1.0d0) |
|---|
| 48 | (erf-q 1.0d0) |
|---|
| 49 | (hazard 1.0d0)) |
|---|
| 50 | |# |
|---|
| 51 | |
|---|
| 52 | (LISP-UNIT:DEFINE-TEST ERROR-FUNCTIONS |
|---|
| 53 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 54 | (LIST 0.8427007929497149d0 7.789237746491556d-16) |
|---|
| 55 | (MULTIPLE-VALUE-LIST (ERF 1.0d0))) |
|---|
| 56 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 57 | (LIST 0.1572992070502851d0 4.0468944536809554d-16) |
|---|
| 58 | (MULTIPLE-VALUE-LIST (ERFC 1.0d0))) |
|---|
| 59 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 60 | (LIST -1.8496055099332485d0 3.394126565390616d-15) |
|---|
| 61 | (MULTIPLE-VALUE-LIST (LOG-ERFC 1.0d0))) |
|---|
| 62 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 63 | (LIST 0.24197072451914334d0 1.611848817878303d-16) |
|---|
| 64 | (MULTIPLE-VALUE-LIST (ERF-Z 1.0d0))) |
|---|
| 65 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 66 | (LIST 0.15865525393145707d0 2.832400331480832d-16) |
|---|
| 67 | (MULTIPLE-VALUE-LIST (ERF-Q 1.0d0))) |
|---|
| 68 | (LISP-UNIT::ASSERT-NUMERICAL-EQUAL |
|---|
| 69 | (LIST 1.5251352761609807d0 5.532094155354489d-15) |
|---|
| 70 | (MULTIPLE-VALUE-LIST (HAZARD 1.0d0)))) |
|---|
| 71 | |
|---|