Rick said:
Is there a way to use Excel's statistical functions in an Access query? I
would like to generate a gamma distribution and can do so in Excel using the
GAMMADIST() function. However, it does not appear as though Access can
utilize these functions? Is there something I need to do to be able to
access these functions?
THanks,
Rick
After reading this thread I decided to take a try at a Gamma function in
Access. The Gamma function could be part of a potential solution in
Access to this problem. My first attempt was based on an Euler integral
form found at
www.mathworld.com.
http://mathworld.wolfram.com/GammaFunction.html
gamma(z) := Integral from 0 to 1 of [ln(1/t)] ^ (z-1) dt.
To solve Integral from 0 to 1 of G(t,z) dt (z fixed), brute force method:
'---Begin Module Code---
Public Function Gamma(dblZ As Double) As Double
Dim dblAreaSum As Double
Dim lngN As Long
Dim lngI As Long
Dim dblDeltaT As Double
lngN = 10000000
dblDeltaT = CDbl(1 / lngN)
dblAreaSum = 0
For lngI = 1 To lngN
dblAreaSum = dblAreaSum + G((lngI - 0.5) * dblDeltaT, dblZ)
Next lngI
Gamma = dblAreaSum * dblDeltaT
End Function
Public Function G(dblT As Double, dblZ As Double) As Double
G = Log(1 / dblT) ^ (dblZ - 1)
End Function
'---Begin Module Code---
MsgBox (Gamma(4)) => 5.9999651 (instead of the actual value of 6.00000)
It ran a little slowly.
The next step was to use two different step sizes with the step size
above for the first 10% of the time domain and then a step size that is
10 times larger. That ran about nine times faster and produced almost
exactly the same result for an input value of 4. I'm not suggesting
abandoning the Excel functions at all here. This was just a small
programming exercise. I think the equivalent of factorials is going to
play havoc with the numerical accuracy without some clever programming
so the warning about thorough testing applies doubly to this problem.
James A. Fortune
(e-mail address removed)