Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Gamma Function

JohnNichols
Valued Contributor III
848 Views

Jim:

I have been putting in the calculation for the t Stat for the bridge stats check.  

The t stat function involves gamma, the t stat function uses the number of degrees of freedom,  but the Fortran gamma function goes to infinity with n of 170, the t stat tables are all close to the range 0 to 5 , the tables list a dof of infinity, 170 is not infinity it is actually quite a small stats data set. 

Screenshot 2024-02-20 110818.png

 

 program Console9

 implicit none
 integer i
 real*8 g, f

 ! Variables

 ! Body of Console9
 print *, 'Hello World'
 f = 0.0
 do i = 1, 1000
 f = f+ 1.0
 g = gamma(f)
 write(*,*)i,f,g
 
 end do
 

 end program Console9

This is the result from this simple program.  

I was looking at the EXCEL function for t Stat in their data analysis, they quite comfortably say they are calculating a t stat for a dof of several thousand in their linear regression models.  

I tried fitting a curve through their t stat data, but one cannot fit a simple curve, 

I was wondering, just as a thought experiment, how these publishers of a t STAT table can say they know infinity, infinity divided by infinity is still infinity.  And how the heck does EXCEL do a calculation I cannot do in Fortran, unless they use an extrapolation function. 

Anyway, enough complaining, thankfully I do not have to write a gamma function.  

 

 

 

0 Kudos
2 Replies
jimdempseyatthecove
Honored Contributor III
825 Views

The exponent overflowed that of REAL*8 at step 172

If you use REAL*16...

jimdempseyatthecove_0-1708457173496.png

Now if these are correct, I cannot say. The online calculators I came across do not show up to 1000

 

Jim

JohnNichols
Valued Contributor III
815 Views

thanks,  LOL where did the real16 come from?  I have not seen it before, maybe I am stuck in 1988 with Fortran 3.13.  

Johnson's Probability and Statistics for Engineers  provides a simple problem for the solution of the linear regression with all of the confidence limits, t stat etc.. 

I have been trying to line his model and method up with the EXCEL results, so I can check the code, much faster to just code it than use EXCEL. I am sick of looking up t STAT tables as well. 

But Johnson and EXCEL use the same name for different things, just annoying and Johnson jumps all over the place so it is hard to convert to code without spending hours looking at the example, excel and then the errors.  

EXCEL determines the standard error using the confidence limit equation, which is different to Johnson's standard error definition.  

It would be nice if we all agreed on standard terms.  

 

 

Reply