I have also tried with continued fraction method to calculate Erf which is
as follows.
Erf(1.744196)=1/1.744196+ (1/2)/1.744196+ 1/1.744196+ (3/2)/1.744197+
2/1.744196+ = 0.508553 and this is quite different from the above one.
Hi. I see that you have it working. Just for feedback, in the continued
fraction equation, you had it correct, you were just missing the leading
part of the equation. Instead of writing it out long form, here is a custom
function. You should see that part you were missing.
Function ERF(z)
'// ============================
'// Continued Fraction
'// ============================
Dim Num
Dim t
Dim tt
t = z
For Num = 100 To (1 / 2) Step -(1 / 2)
t = z + Num / t
Next Num
t = 1 / t
'// You were missing this part...
tt = Exp(-(z ^ 2)) / Sqr(WorksheetFunction.Pi)
ERF = 1 - tt * t
End Function
?ERF(1.744196)
0.98636223631017
Which is pretty accurate according to another math program...
Erf[1.744196]
0.9863622363101697
Hope this helps. :)
--
Dana DeLouis
Win XP & Office 2003
"Rijan" wrote in message
...
Dear Jerry,
Still I could not calculate NORMDIST. Here is my problem again,
NORMDIST(0.3,4,1.5,TRUE)=NORMSDIST((0.3-4)/1.5)=NORMSDIST(-2.46667)=(1-Efr(-(-2.466666)/(SQRT2)))/2=(1-Erf(1.744196))/2
Erf(1.744196)=1-(e^-(1.744196)^2)/(SQRT(pi))*(1/1.744196 -
(1/2)*(1/(1.744196)^3) + (3/4)*(1/(1.744196)^5) -
(15/8)*(1/(1.744196)^7)=0.986878
Then with this Erf=0.986878, the NORMSDIST(-2.46667) becomes 0.006560. But
it should be 0.006819. For this result the Erf should be 0.986362 which is
not giving by the above formula.
I have also tried with continued fraction method to calculate Erf which is
as follows.
Erf(1.744196)=1/1.744196+ (1/2)/1.744196+ 1/1.744196+ (3/2)/1.744197+
2/1.744196+ = 0.508553 and this is quite different from the above one.
Would you please let me know what is wrong with the above calculations?
Regards
Rijan
"Jerry W. Lewis" wrote:
Both formulas are correct, but the range of application is a bit off.
The second formula is an asymptotic expansion. That means that if you
use enough terms, it will fail to converge for any finite z. You can
stop the sum when the next term is larger in magnitude than the previous
one, but you would need to use a larger change point (z2) before using
the second formula.
That asymptotic expansion can be converted to to a continued fraction,
Abramowitz & Stegun equation 7.1.14
http://jove.prohosting.com/~skripty/page_298.htm
that is absolutely convergent for all positive z. You would switch
between your first formula and the continued fraction around z=2.
Jerry
Rijan wrote:
Dear Jerry and Dana,
Thanks for your replies. But still I could not calculate NORMDIST
without
using Excel. Would you please check the following equations which I
have used
for ERF?
For z less than 1, ERF = 2/SQRT (pi) * e^(-z^2) * z (1+ (2z^2)/3 +
((2z^2)^2)/15 + .
For z greater than 1, ERF = 1- (e^(-z^2))/(SQRT(pi)) * (1/z - 1/(2z^3)
+
3/(4z^5) -..)