Email List: Xaustin-review-lX
[All Lists]

Re: Defect in XSH exp (revised I)

To: yyyyyyyyyyyyyyy@xxxxxxxxxxxxx
Subject: Re: Defect in XSH exp (revised I)
From: Loic Domaigne <yyyyyyyy@xxxxxxx>
Date: Thu, 17 Jul 2003 18:21:13 +0200 (MEST)
References: <20030716164631.GC39470@finch-staff-1.thus.net>
Hi, 

The revised version for the exp() example.

Loic.
------------------------------------------------------------------------

Computing the density of the standard normal distribution

This function shows a straightforward implementation for
the density of the standard normal distribution using exp()

double
normal_density (double  x
                )
{ 
  return exp(-x*x/2) / sqrt (2*M_PI);
}

Note: For real life problems, where normal_density() is called many, 
many times (let's say 10 millions or more), this implementation
is not particularly efficient.  Possible improvements include:

- compute the constant term sqrt(2*M_PI) only once.
- transform the division to a multiplication. 

If you are planning to do serious numerical works, get a good 
book on numerical computations or advices from an expert.
[ I guess this last advice applies to all XSH math functions ]

-- 
+++ GMX - Mail, Messaging & more  http://www.gmx.net +++

Jetzt ein- oder umsteigen und USB-Speicheruhr als Prämie sichern!

<Prev in Thread] Current Thread [Next in Thread>