help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Integrating a normal distribution many times


From: Quentin Spencer
Subject: Re: Integrating a normal distribution many times
Date: Thu, 17 May 2007 08:05:04 -0500
User-agent: Thunderbird 1.5.0.10 (X11/20070302)

Søren Hauberg wrote:
Hi,
   This is not necessarily an Octave question. but here goes anyway.
I need to evaluate the integrate a normal distribution over a specific interval with many mean values. My current Octave implementation just calls 'quad' at mean value, i.e.

for t = linspace(0, 32, 750)
   qq = @(x) normal_pdf(x, t, 2.5);
   result = quad(qq, 19, 26, 0)
endfor

This is, however, fairly slow. At some point my system needs to run in real-time (not in an Octave implementation), so I doubt that the above strategy will work. Does anybody have some hints on how to speed this up? Should I precalculate a lookup table with some values and then interpolate when I need to evaluate the function at a new mean value?

The best way to make this faster in octave is to use the error function ("erf" in octave). Any integral of the normal probability density function can be expressed in terms of the error function. If you eventually need this in C, I don't know whether math.h includes erf or not, but you might look at how octave is computing it.


Quentin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]