skip to main content

Algorithm 885: Computing the Logarithm of the Normal Distribution

Published:01 October 2008Publication History
Skip Abstract Section

Abstract

We present and compare three C functions to compute the logarithm of the cumulative standard normal distribution. The first is a new algorithm derived from Algorithm 304’s calculation of the standard normal distribution via a series or continued fraction approximation, and it is good to the accuracy of the machine. The second is based on Algorithm 715’s calculation of the standard normal distribution via rational Chebyshev approximation. This is related to, and an improvement on, the algorithm for the logarithm of the normal distribution available in the software package R. The third is a new and simple algorithm that uses the compiler’s implementation of the error function, and complement of the error function, to compute the log of the normal distribution.

Skip Supplemental Material Section

Supplemental Material

References

  1. Abramowitz, M. and Stegun, I., Eds. 1972. Handbook of Mathematical Functions. Dover, New York, NY.Google ScholarGoogle Scholar
  2. Adams, A. G. 1969a. Algorithm 39: Areas under the normal curve. Comput. J. 12, 197--198.Google ScholarGoogle Scholar
  3. Adams, A. G. 1969b. Remark on Algorithm 304. Commun. ACM 12, 10, 565--566. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Brophy, A. L. and Wood, D. L. 1989. Algorithms for fast and precise computation of the normal integral. Behav. Res. Meth. Instr. Comput. 21, 447--454.Google ScholarGoogle ScholarCross RefCross Ref
  5. Clenshaw, C., Ed. 1962. Chebyshev Series for Mathematical Functions. National Physical Laboratory Mathematical Tables, volume 5. Her Majesty’s Stationery Office, London.Google ScholarGoogle Scholar
  6. Cody, W. J. 1969. Rational Chebyshev approximations for the error function. Math. Computation 23, 631--637.Google ScholarGoogle ScholarCross RefCross Ref
  7. Cody, W. J. 1993. Algorithm 715: SPECFUN --- a portable FORTRAN package of special function routines and test drivers. ACM Trans. Math. Softw. 19, 22--32. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Cooper, B. E. 1968. Algorithm AS2: the normal integral. Appl. Statis. 17, 186--188.Google ScholarGoogle ScholarCross RefCross Ref
  9. Fletcher, A. and Rosenhead, L. 1962. Index of Mathematical Tables, 2nd ed. Scientific Computing Service Limited, London.Google ScholarGoogle Scholar
  10. Hart, J. F., Cheney, E. W., Lawson, C. L., Maehly, H. J., Mesztenyi, C. K., Rice, J. R., Thacher, Jr., H. C., and Witzgall, C. Eds. 1968. Computer Approximations. SIAM series in Applied Math. Wiley, New York, NY. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Hill, I. D. 1969. Remark on Algorithm AS2. Appl. Statis. 18, 299--300.Google ScholarGoogle ScholarCross RefCross Ref
  12. Hill, I. D. 1973. Algorithm AS66: the normal integral. Appl. Statis. 22, 424--427.Google ScholarGoogle ScholarCross RefCross Ref
  13. Hill, I. D. and Joyce, S. A. 1967a. Algorithm 304 normal curve integral. Commun. ACM 10, 6, 374--375. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Hill, I. D. and Joyce, S. A. 1967b. Remarks on: Algorithm 123, Algorithm 180, Algorithm 181, Algorithm 209, Algorithm 226, Algorithm 272, Algorithm 304. Commun. ACM 10, 6, 377--378. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Holmgren, B. 1970. Remark on Algorithm 304. Commun. ACM 13, 10, 624. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Ibbetson, D. 1963. Algorithm 209: Gauss. Commun. ACM 6, 616. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. IEEE. 1985. IEEE Standard 754-1985 for Binary Floating-Point Arithmetic. The Institute of Electrical and Electronics Engineers, Inc., New York, NY.Google ScholarGoogle Scholar
  18. Marsaglia, G. 2004. Evaluating the normal distribution. J. Statis. Softw. 11, 1--7.Google ScholarGoogle ScholarCross RefCross Ref
  19. Martynov, G. V. 1981. Evaluation of the normal distribution function. J. Sov. Math. 17, 1857--1875.Google ScholarGoogle ScholarCross RefCross Ref
  20. Monahan, J. 1981. Approximating the log of the normal cumulative. In Computer Science and Statistics: Proceedings of the 13th Symposium on the Interface. Springer Verlag, New York, NY, 304--307.Google ScholarGoogle ScholarCross RefCross Ref
  21. Pearson, E. S. and Hartley, H. O., Eds. 1954. Biometrika Tables for Statisticians. Vol. 1. Cambridge University Press, Cambridge, UK.Google ScholarGoogle Scholar
  22. Press, W. H. et al. 1992. Numerical Recipes in C, 2 ed. Cambridge University Press, Cambridge, UK.Google ScholarGoogle Scholar
  23. R Development Core Team. 2007. R: A Language and Environment for Statistical Computing. R Foundation for Statistical Computing, Vienna, Austria. http://www.R-project.org. ISBN (3-900051-07-0).Google ScholarGoogle Scholar
  24. Schonfelder, J. L. 1978. Chebyshev expansions for the error and related functions. Math. Computation 32, 144, 1232--1240.Google ScholarGoogle Scholar
  25. Sheppard, W. F., Ed. 1939. The Probability Integral. British Association for the Advancement of Science, Mathematical Tables, vol. 7. Cambridge, University Press, Cambridge, UK.Google ScholarGoogle Scholar
  26. Zeileis, A. and Kleiber, C. 2005. Validating multiple structural change models --- a case study. J. Appl. Econometrics 20, 685--690.Google ScholarGoogle ScholarCross RefCross Ref

Index Terms

  1. Algorithm 885: Computing the Logarithm of the Normal Distribution

          Recommendations

          Reviews

          Marlin W Thomas

          Calculating the logarithm rapidly and accurately of points on the standard normal curve-a normal curve with mean of zero and standard deviation of one-is required for applications that involve repeated determinations of the logarithm. This paper points out the relative lack of discussion of the subject in the literature, surveys what there is of its history, presents the algorithm, describes three of its implementations along with empirical results, and provides the means of selecting one of the algorithms, based on requirements of speed and accuracy. In a brief but insightful review of the literature calculating the logarithm of the standard normal distribution, Linhart identifies a problem with accuracy in the tails of the curve and presents three candidate solutions to remedy the problem. One uses continued fractions, another uses rational Chebyshev approximations, and the third uses a compiler resident error function. Although the paper focuses on C implementations of the algorithm, a major feature is the analysis of the algorithm independent of its implementation; it makes a contribution to the literature by noting the negative effect of points at the extremes. One of the goals of the paper is to isolate ways to moderate this effect. A valuable feature of the paper is its presentation of testing results regarding error ranges. The paper provides a valuable resource for applied statisticians and for programmers interested in the implementation of statistical algorithms. Online Computing Reviews Service

          Access critical reviews of Computing literature here

          Become a reviewer for Computing Reviews.

          Comments

          Login options

          Check if you have access through your login credentials or your institution to get full access on this article.

          Sign in

          Full Access

          • Published in

            cover image ACM Transactions on Mathematical Software
            ACM Transactions on Mathematical Software  Volume 35, Issue 3
            October 2008
            164 pages
            ISSN:0098-3500
            EISSN:1557-7295
            DOI:10.1145/1391989
            Issue’s Table of Contents

            Copyright © 2008 ACM

            Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

            Publisher

            Association for Computing Machinery

            New York, NY, United States

            Publication History

            • Published: 1 October 2008
            • Revised: 1 January 2008
            • Accepted: 1 January 2008
            • Received: 1 November 2007
            Published in toms Volume 35, Issue 3

            Permissions

            Request permissions about this article.

            Request Permissions

            Check for updates

            Qualifiers

            • research-article
            • Research
            • Refereed

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader