TPCCLIB
Loading...
Searching...
No Matches
normaldistr.c File Reference

Functions for using normal distribution. More...

#include "libtpcmodel.h"

Go to the source code of this file.

Functions

double ndtr (double a)
 
double normal_pvalue_2 (double x)
 
double normal_pvalue_1 (double x)
 

Detailed Description

Functions for using normal distribution.

Author
Kaisa Liukko, Vesa Oikonen

Definition in file normaldistr.c.

Function Documentation

◆ ndtr()

double ndtr ( double a)

Calculates the area under the Gaussian probability density function integrated from minus infinity to given value a. For more information search for the Cephes C codes.

Returns
Returns the area under the Gaussian probability density function, integrated from minus infinity to a.
Parameters
avariable a

Definition at line 17 of file normaldistr.c.

20 {
21 double x, y, z;
22
23 x=a*M_SQRT1_2;
24 z=fabs(x);
25
26 if(z<1.0) {
27 y=0.5+0.5*erf(x);
28 } else {
29 y=0.5*erfc(z);
30 if(x>0) y=1.0-y;
31 }
32 return(y);
33}

Referenced by normal_pvalue_1(), normal_pvalue_2(), and runs_test().

◆ normal_pvalue_1()

double normal_pvalue_1 ( double x)

Calculates the one-sided p-value for x in relation to the standard normal distribution (that is, the probability that a random variable distributed as N(0, 1) is greater than x).

Returns
Returns 1 minus the value of the standard normal CDF evaluated at x.
Parameters
xdouble-precision value x

Definition at line 60 of file normaldistr.c.

63 {
64 return 1.0-ndtr(x);
65}
double ndtr(double a)
Definition normaldistr.c:17

◆ normal_pvalue_2()

double normal_pvalue_2 ( double x)

Calculates the two-sided p-value for x in relation to the standard normal distribution.

Returns
Returns 2 times (1 minus the value of the standard normal CDF evaluated at |x|).
Parameters
xdouble-precision value x

Definition at line 43 of file normaldistr.c.

46 {
47 double p = (x<0.0)? ndtr(x) : ndtr(-x);
48 return 2.0*p;
49}