View Single Post
  #7   Report Post  
 
Posts: n/a
Default t-distribution puzzle in Excel


Jerry W. Lewis wrote:
mm wrote:

...

Btw, is inv_tdist in public domain?

...


The first line of the VBA code is a copyright notice, so by definition,
it is not public domain.

However, if Ian Smith had not intended for individuals to use his code,
then I doubt that he would have published the source code in a public
place. If you are wanting to use it commercially, I would recommend
e-mailing him. His address ) is clearly displayed
on his web page
http://members.aol.com/iandjmsmith/
and I have found him to respond readily to communications regarding his
numerical analysis efforts. Ian?

Jerry


Any time I suggest someone might wish to use the code, I try to make it
clear that they can do anything they like with it. I place no
restrictions and give no guarantees although I believe the code is
pretty much as good as you will find. I do not see the point in having
everyone write code for the same old stuff over and over again. It
seems to defeat the main point of computer programs which is that you
only have to get it right once and it'll work forever. I have no
problems with the code being used commercially. Should anyone make a
fortune because of its use, they are more than welcome to shower me
with gifts/donations. So Microsoft, please note, I have no problem if
this code or better is added to Excel making my VBA code redundant!

The code has a copyright notice at the top because when I first made
the code available, I consulted some online document on copyright
issues and it said I should include it. It also said I have the
copyright whether or not I add it in because I produced the code or
some such stuff. Please note, the code for AS241 is merely a
translation and so from a copyright point of view has nothing to do
with me. This may have implications about it's commercial use. I
believe it is ok to use AS241 (and translations of it) commercially but
one thing I am not is a legal expert. I do not even know exactly what
"in the public domain" implies.

The main purpose of the code is to provide accurate methods of
performing basic calculations for statistical distributions.

It also shows how simple modifications to techniques such as
Newton-Raphson can improve them enormously. I think that's why the
inv_tdist code is much faster than the Excel TINV code despite VBA not
being particularly quick. Excel claims to use a binary search which
would require the TDIST function to be called lots of times. I have not
seen the modified NR approach call the cdf function more than 7 times.

The code also includes asymptotic formulae and continued fraction
formulae which I've discovered over the years and have not seen
elsewhere.

Lastly, it shows how write statistical functions without using a
function to evaluate the log of the gamma function - a pet hate of mine
because its use guarantees large errors if applied to large arguments.
Again you only have to get it right once and unnecessary errors of that
type need never reappear.

What the code is not intended to do is probably just as important.

It is not intended to be the fastest, the most accurate or best in any
sense.

I believe all of the code can be improved (made faster or more accurate
or work with logs of probabilities to avoid returning probabilities of
0 ...) but the code is a good place to start from.

The code can usually be modified easily. If, for example, you wish to
calculate functions of the t-distribution for non-integral degrees of
freedom just comment out the lines like df = Fix(df) in the pdf, cdf
and inv functions. The code does not make use of the fact that it is
restricted to integral degrees of freedom.


Ian Smith