Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Curve Fitting A Gamma function

Status
Not open for further replies.

chicopee

Mechanical
Feb 15, 2003
6,199
Can Excel curve fit discrete data points which when plotted produce a rough gamma curve. I am trying to get a smooth curve from my data points.
 
Replies continue below

Recommended for you

Yes, but no. The gamma function is not a built-in fit within Excel.

But, you should be able to fit the data by using the solver routine to adjust the gamma function coefficients to reduce the residual errors (differences between the fitted function and the data points).

You may want to look at using a Weibull function to fit the data also; although statisticall analysis with a Weibull function is a little more work, it can be useful for other reasons.
 
You can get the Gamma function indirectly by using the natural log of Gamma--the natural log of the Gamma function is built-in within Excel. Here is a function returning the natural log of the Gamma function. There is also the WorksheetFunction GammaLn that can get you there.

Function gammaln2(xx As Double)
' Returns the natural log of the Gamma Function
' Is equivalent to Application.WorksheetFunction.GammaLn
Dim ser As Double, stp As Double, tmp As Double, x As Double, y As Double
Dim cof(6) As Double
Dim j As Integer
cof(1) = 76.1800917294715
cof(2) = -86.5053203294168
cof(3) = 24.0140982408309
cof(4) = -1.23173957245015
cof(5) = 1.20865097386618E-03
cof(6) = -5.395239384953E-06
stp = 2.506628274631
x = xx
y = x
tmp = x + 5.5
tmp = (x + 0.5) * Log(tmp) - tmp
ser = 1.00000000019001
For j = 1 To 6
y = y + 1#
ser = ser + cof(j) / y
Next j
gammaln2 = tmp + Log(stp * ser / x)
End Function
 
Prost,
My Gamma function is :I(t)=P*t^s*e^(-f*t)
The natural log is :ln(t)=lnP+s*ln(t)-f*t
The linear equivalent:y= B(0)+ B(1)X(1)+B(2)X(2)

Now how do you propose the use your method with the above.
I should also mentioned that I did a regression for two independent variables which in my case would be X(1) and
X(2) and my result was 962*t^(4.12E-04)*e^(-8.52E-17). When plotted this equation looked atrocious. I did not even bother doing an error computation.
 
The Gamma function I know is an integral, so I have no idea what "P" is for you. My book shows:
Gamma(n)=integral(t^(n-1)*exp(-t)).

The only other forms for Gamma function I have found are asymptotic series expansions.

I don't understand what the question; I just checked the function--it returns ln(Gamma). Just use exponent "e" to convert to Gamma.

 
A Gamma function is different from a Gamma distribution.

I think chicopee is needing a Gamma distribution, which apparently Excel can now provide
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor