summaryrefslogtreecommitdiffstats
path: root/nist/special-functions.c
blob: c15b7e13f2eea5b59e3cdb5da9d12b67e7a8e9c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <stdio.h>
#include <math.h>
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
                     S P E C I A L  F U N C T I O N S 
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#define LinuxorUnix
#ifdef WIN
#ifndef CYGWIN
#undef LinuxorUnix
/* same libraries are available*/
#endif
#endif

#ifdef LinuxorUnix
double normal(double x)
{
  double arg, result, sqrt2=1.414213562373095048801688724209698078569672;

  if (x > 0) {
    arg = x/sqrt2;
    result = 0.5 * ( 1 + erf(arg) );
  }
  else {
    arg = -x/sqrt2;
    result = 0.5 * ( 1 - erf(arg) );
  }
  return( result);
}

double normal2(double a)
{ return (1.0-0.5*erfc(a/sqrt(2.0))); }
#endif