~ubuntu-branches/ubuntu/utopic/mricron/utopic

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
{ ******************************************************************
  Density of standard normal distribution
  ****************************************************************** }

unit unormal;

interface

uses
  utypes;

function DNorm(X : Float) : Float;
{ Density of standard normal distribution }

implementation

function DNorm(X : Float) : Float;
var
  Y : Float;
begin
  Y := - 0.5 * X * X;
  if Y < MinLog then
    DNorm := DefaultVal(FUnderflow, 0.0)
  else
    begin
      SetErrCode(FOk);
      DNorm := InvSqrt2Pi * Exp(Y);
    end;
end;

end.