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
[] =
16
"erf.cpp,v 1.5 1997/11/24 16:21:37 hines Exp"
;
17
#endif
18
19
/************************************************************
20
*
21
* Abstract: erf()
22
*
23
* Normalized error function.
24
*
25
* erf(z) = (2/sqrt(PI)) * Integral from 0 to z of
26
* exp(-t*t) dt
27
*
28
* Note that erf(-z) = -erf(z). To obtain the cumulative
29
* Gaussian distribution function at z probits:
30
*
31
* z = (x - mean)/std_dev
32
* cdf(z) = 0.5 * (1 + erf(z))
33
*
34
* Calling sequence: erf(z)
35
*
36
* Argument: Input: z, double
37
*
38
* Functions called: none
39
*
40
* Returns: double precision value of error function is on
41
* the interval [-1, 1]
42
*
43
* Files accessed: none
44
*
45
***********************************************************/
46
47
#include <
math.h
>
48
#define a1 0.254829592
49
#define a2 -0.284496736
50
#define a3 1.421413741
51
#define a4 -1.453152027
52
#define a5 1.061405429
53
double
54
erf
(z)
55
double
z;
56
{
57
double
t
,
value
;
58
59
t = 1. / (1. + 0.3275911 *
fabs
(z));
60
value = 1. - (((((a5 * t + a4) * t + a3) * t + a2) * t + a1) *
t
) *
exp
(-z * z);
61
62
if
(z >= 0.0)
63
return
(value);
64
else
65
return
(-value);
66
}
67
68
double
69
erfc(z)
70
double
z;
71
{
72
return
1. -
erf
(z);
73
}
74
#endif
75
#endif
math.h
exp
exp
Definition:
extdef.h:3
value
static uint32_t value
Definition:
scoprand.cpp:26
fabs
fabs
Definition:
extdef.h:3
t
double t
Definition:
init.cpp:123
RCSid
static char RCSid[]
Definition:
scoprand.cpp:20
erf
erf
Definition:
extdef.h:3
src
oc
ocerf.cpp