gdtrl.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* gdtrl.c
  2. *
  3. * Gamma distribution function
  4. *
  5. *
  6. *
  7. * SYNOPSIS:
  8. *
  9. * long double a, b, x, y, gdtrl();
  10. *
  11. * y = gdtrl( a, b, x );
  12. *
  13. *
  14. *
  15. * DESCRIPTION:
  16. *
  17. * Returns the integral from zero to x of the gamma probability
  18. * density function:
  19. *
  20. *
  21. * x
  22. * b -
  23. * a | | b-1 -at
  24. * y = ----- | t e dt
  25. * - | |
  26. * | (b) -
  27. * 0
  28. *
  29. * The incomplete gamma integral is used, according to the
  30. * relation
  31. *
  32. * y = igam( b, ax ).
  33. *
  34. *
  35. * ACCURACY:
  36. *
  37. * See igam().
  38. *
  39. * ERROR MESSAGES:
  40. *
  41. * message condition value returned
  42. * gdtrl domain x < 0 0.0
  43. *
  44. */
  45. /* gdtrcl.c
  46. *
  47. * Complemented gamma distribution function
  48. *
  49. *
  50. *
  51. * SYNOPSIS:
  52. *
  53. * long double a, b, x, y, gdtrcl();
  54. *
  55. * y = gdtrcl( a, b, x );
  56. *
  57. *
  58. *
  59. * DESCRIPTION:
  60. *
  61. * Returns the integral from x to infinity of the gamma
  62. * probability density function:
  63. *
  64. *
  65. * inf.
  66. * b -
  67. * a | | b-1 -at
  68. * y = ----- | t e dt
  69. * - | |
  70. * | (b) -
  71. * x
  72. *
  73. * The incomplete gamma integral is used, according to the
  74. * relation
  75. *
  76. * y = igamc( b, ax ).
  77. *
  78. *
  79. * ACCURACY:
  80. *
  81. * See igamc().
  82. *
  83. * ERROR MESSAGES:
  84. *
  85. * message condition value returned
  86. * gdtrcl domain x < 0 0.0
  87. *
  88. */
  89. /* gdtrl() */
  90. /*
  91. Cephes Math Library Release 2.3: March, 1995
  92. Copyright 1984, 1995 by Stephen L. Moshier
  93. */
  94. #include <math.h>
  95. #ifdef ANSIPROT
  96. extern long double igaml ( long double, long double );
  97. extern long double igamcl ( long double, long double );
  98. #else
  99. long double igaml(), igamcl();
  100. #endif
  101. long double gdtrl( a, b, x )
  102. long double a, b, x;
  103. {
  104. if( x < 0.0L )
  105. {
  106. mtherr( "gdtrl", DOMAIN );
  107. return( 0.0L );
  108. }
  109. return( igaml( b, a * x ) );
  110. }
  111. long double gdtrcl( a, b, x )
  112. long double a, b, x;
  113. {
  114. if( x < 0.0L )
  115. {
  116. mtherr( "gdtrcl", DOMAIN );
  117. return( 0.0L );
  118. }
  119. return( igamcl( b, a * x ) );
  120. }