Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default related to error function

How to find inverse of complementary error and error function
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 39
Default related to error function

Hummm? Please refrase or expand your question.

Argy

"amit saraf" wrote:

How to find inverse of complementary error and error function

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 947
Default related to error function

amit saraf wrote:
How to find inverse of complementary error and error function


Hi. If you don't get a better solution, here is a Newton version
of the Inverse Error function. The normal Series equation converges too
slowly in my opinion.
Note that Excel's ERF() function can't work with Negative values (it's a
known bug). This tries to work around it.
As a simple test, we try to get back the same values...

Sub TestIt()
Debug.Print InverseERF([Erf(.1)])
Debug.Print InverseERF([Erf(.9)])
Debug.Print InverseERF([Erf(2)])
Debug.Print InverseERF([-Erf(2)])
End Sub


Function InverseERF(N)
Dim J As Long 'Counter
Dim G As Double 'Guess
Dim Ng As Double 'New Guess
Dim K As Double 'Constant
Dim M As Double 'Hold Positive value of n

Select Case N
Case -1
InverseERF = "-Infinity"
Case 1
InverseERF = "+Infinity"
Case -1 To 1
'Valid
With WorksheetFunction
K = [SqrtPi(1)/2]
Ng = 0.5
M = Abs(N)
Do
G = Ng
Ng = G + K * Exp(G * G) * (.ErfC(G) + M - 1)
J = J + 1
Loop While G < Ng And J < 30
'It's a Odd function, so ok.
InverseERF = Sgn(N) * Ng
End With
Case Else
InverseERF = "Invalid"
End Select
End Function

- - -
HTH
Dana DeLouis
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default related to error function


You can use these, with a reference to atpvbaen.

Code:
--------------------
' The worksheet ERF and ERFC functions only allow non-negative
' arguments less than about 27.334, although the mathematical functions are valid
' across the domain of Reals. The ERF function reaches its asymptotic limit of 1
' (to double precision accuracy) by 5.8

' The functions myERF and myERFC are identical in interface to the worksheet
' functions, but work for any value of the arguments.

Function myERF(a As Double, Optional b As Variant)
myERF = myERF1(a)
If Not IsMissing(b) Then myERF = myERF1(CDbl(b)) - myERF
End Function

Function myERFC(x As Double) As Double
myERFC = 1# - myERF(x)
End Function

Private Function myERF1(x As Double) As Double
If Abs(x) 5.8 Then
myERF1 = Sgn(x)
ElseIf x < 0 Then
myERF1 = Sgn(x) * Application.Run("ATPVBAEN.XLA!ERF", Abs(x))
End If
End Function

--------------------


--
shg
------------------------------------------------------------------------
shg's Profile: http://www.thecodecage.com/forumz/member.php?userid=13
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=26920

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 837
Default related to error function

Use the relationship between these functions and functions for which Excel
does have inverses.
ERF(x) = GAMMADIST(x^2,0.5,1,TRUE)
ERFC(x) = 2*NORMSDIST(-x*SQRT(2)) = CHIDIST(2*x^2,1)
so
invERF(p) = SQRT(GAMMAINV(p,0.5,1))
invERFC(p) = -NORMSINV(p/2)/SQRT(2) = SQRT(CHIINV(p,1)/2)

For Excel 2003 or later, NORMSDIST and NORMSINV are much more accurate than
ERFC for large values of x. For earlier versions of Excel, CHIDIST is more
accurate than ERFC, but neither inverse function performs well for large x
(small p).

Jerry

"amit saraf" wrote:

How to find inverse of complementary error and error function

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel related Thiyagu Charts and Charting in Excel 1 June 5th 08 12:26 PM
two related workfiles Hank Excel Discussion (Misc queries) 4 March 7th 08 09:20 PM
2 questions! Related to combobox and time function. HELP!! Bruno Excel Discussion (Misc queries) 11 September 28th 07 02:33 PM
macro related Ankur Excel Discussion (Misc queries) 3 August 17th 05 11:26 AM
Function Related Question Sandeep Arora Excel Discussion (Misc queries) 1 February 2nd 05 07:36 PM


All times are GMT +1. The time now is 07:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"