The IBETA function computes the incomplete beta function.
This routine is written in the IDL language. Its source code can be found in the file ibeta.pro in the lib subdirectory of the IDL distribution.
Result = IBETA( A, B, Z [, /DOUBLE] [, EPS=value] [, ITER=variable] [, ITMAX=value] )
If all arguments are scalar, the function returns a scalar. If all arguments are arrays, the function matches up the corresponding elements of A, B, and Z, returning an array with the same dimensions as the smallest array. If one argument is a scalar and the other arguments are arrays, the function uses the scalar value with each element of the arrays, and returns an array with the same dimensions as the smallest input array.
If any of the arguments are double-precision or if the DOUBLE keyword is set, the result is double-precision, otherwise the result is single-precision.
A scalar or array that specifies the parametric exponent of the integrand. A may be complex.
A scalar or array that specifies the parametric exponent of the integrand. B may be complex.
A scalar or array, in the interval [0, 1], that specifies the upper limit of integration. Z may be complex. If Z is not complex then the values must be in the range [0, 1].
Set this keyword to force the computation to be done in double precision.
Set this keyword to the desired relative accuracy, or tolerance. The default tolerance is 3.0e-7 for single precision, and 3.0d-12 for double precision.
Set this keyword to a named variable that will contain the actual number of iterations performed.
Set this keyword to specify the maximum number of iterations. The default value is 100.
This routine is written to make use of IDL's thread pool, which can increase execution speed on systems with multiple CPUs. The values stored in the
Compute the incomplete beta function for the corresponding elements of A, B, and Z.
; Define an array of parametric exponents: A = [0.5, 0.5, 1.0, 5.0, 10.0, 20.0] B = [0.5, 0.5, 0.5, 5.0, 5.0, 10.0] ; Define the upper limits of integration: Z = [0.01, 0.1, 0.1, 0.5, 1.0, 0.8] ; Compute the incomplete beta functions: result = IBETA(A, B, Z) PRINT, result
IDL prints:
[0.0637686, 0.204833, 0.0513167, 0.500000, 1.00000, 0.950736]
This example shows the difference in accuracy between the incomplete beta function computed with a low tolerance and the incomplete beta function computed with a high tolerance. The resulting surfaces show the relative errors of each. The relative error of the low tolerance ranges from 0 to 0.002 percent. The relative error of the high tolerance ranges from 0 to 0.0000000004 percent.
PRO UsingIBETAwithEPS ; Define an array of parametric exponents. parameterA = (DINDGEN(101)/100. + 1.D) # REPLICATE(1.D, 101) parameterB = REPLICATE(1.D, 101) # (DINDGEN(101)/10. + 1.D) ; Define the upper limits of integration. upperLimits = REPLICATE(0.1D, 101, 101) ; Compute the incomplete beta functions. betaFunctions = IBETA(parameterA, parameterB, upperLimits) ; Compute the incomplete beta functions with a less ; accurate tolerance set. laBetaFunctions = IBETA(parameterA, parameterB, $ upperLimits, EPS = 3.0e-4) ; Compute relative error. relativeError = 100.* $ ABS((betaFunctions - laBetaFunctions)/betaFunctions) ; Display resulting relative error. WINDOW, 0, TITLE = 'Compare IBETA with Less Accurate EPS' SURFACE, relativeError, parameterA, parameterB, $ /XSTYLE, /YSTYLE, TITLE = 'Relative Error', $ XTITLE = 'Parameter A', YTITLE = 'Parameter B', $ ZTITLE = 'Percent Error (%)', CHARSIZE = 1.5 ; Compute the incomplete beta functions with a more ; accurate tolerance set.. maBetaFunctions = IBETA(parameterA, parameterB, $ upperLimits, EPS = 3.0e-10) ; Compute relative error. relativeError = 100.* $ ABS((maBetaFunctions - betaFunctions)/maBetaFunctions) ; Display resulting relative error. WINDOW, 1, TITLE = 'Compare IBETA with More Accurate EPS' SURFACE, relativeError, parameterA, parameterB, $ /XSTYLE, /YSTYLE, TITLE = 'Relative Error', $ XTITLE = 'Parameter A', YTITLE = 'Parameter B', $ ZTITLE = 'Percent Error (%)', CHARSIZE = 1.5 in = '' READ,"Press enter",in WDELETE, 0, 1 END
Introduced: 4.0
A, B, and Z arguments accept complex input: 5.6