NEURON
ocerf.cpp
Go to the documentation of this file.
1 #include <../../nrnconf.h>
2 #include <errno.h>
3 #ifndef MINGW
4 #if DOS || defined(__GO32__) || defined(WIN32) /*|| defined(MAC)*/
5 /******************************************************************************
6  *
7  * File: erf.cpp
8  *
9  * Copyright (c) 1988, 1989, 1990
10  * Duke University
11  *
12  ******************************************************************************/
13 
14 #ifndef LINT
15 static char RCSid[] = "erf.cpp,v 1.5 1997/11/24 16:21:37 hines Exp";
16 #endif
17 
18 /************************************************************
19  *
20  * Abstract: erf()
21  *
22  * Normalized error function.
23  *
24  * erf(z) = (2/sqrt(PI)) * Integral from 0 to z of
25  * exp(-t*t) dt
26  *
27  * Note that erf(-z) = -erf(z). To obtain the cumulative
28  * Gaussian distribution function at z probits:
29  *
30  * z = (x - mean)/std_dev
31  * cdf(z) = 0.5 * (1 + erf(z))
32  *
33  * Calling sequence: erf(z)
34  *
35  * Argument: Input: z, double
36  *
37  * Functions called: none
38  *
39  * Returns: double precision value of error function is on
40  * the interval [-1, 1]
41  *
42  * Files accessed: none
43  *
44  ***********************************************************/
45 
46 #include <math.h>
47 #define a1 0.254829592
48 #define a2 -0.284496736
49 #define a3 1.421413741
50 #define a4 -1.453152027
51 #define a5 1.061405429
52 double erf(double z) {
53  double t, value;
54 
55  t = 1. / (1. + 0.3275911 * fabs(z));
56  value = 1. - (((((a5 * t + a4) * t + a3) * t + a2) * t + a1) * t) * exp(-z * z);
57 
58  if (z >= 0.0)
59  return (value);
60  else
61  return (-value);
62 }
63 
64 double erfc(double z) {
65  return 1. - erf(z);
66 }
67 #endif
68 #endif
double t
Definition: cvodeobj.cpp:59
exp
Definition: extdef.h:5
fabs
Definition: extdef.h:3
erf
Definition: extdef.h:7
static char RCSid[]
Definition: scoprand.cpp:20
static uint32_t value
Definition: scoprand.cpp:25