README.md (3834B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2018 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # Kernel Betainc 22 23 > [Incomplete beta function][incomplete-beta-function] and its first derivative. 24 25 <section class="intro"> 26 27 </section> 28 29 <!-- /.intro --> 30 31 <section class="usage"> 32 33 ## Usage 34 35 ```javascript 36 var kernelBetainc = require( '@stdlib/math/base/special/kernel-betainc' ); 37 ``` 38 39 #### kernelBetainc( x, a, b, regularized, upper ) 40 41 Evaluates the [incomplete beta function][incomplete-beta-function] and its first derivative for parameters `x`, `a > 0` and `b > 0`. The `regularized` and `upper` boolean parameters are used to specify whether to evaluate the regularized or non-regularized and the upper or lower incomplete beta functions, respectively. 42 43 ```javascript 44 var out = kernelBetainc( 0.8, 1.0, 0.3, false, false ); 45 // returns [ ~1.277, ~0.926 ] 46 47 out = kernelBetainc( 0.2, 1.0, 2.0, true, false ); 48 // returns [ 0.36, 1.6 ] 49 50 out = kernelBetainc( 0.2, 1.0, 2.0, true, true ); 51 // returns [ 0.64, 1.6 ] 52 ``` 53 54 If provided `NaN` for `x`, `a`, or `b`, the function returns `[ NaN, NaN ]`. 55 56 ```javascript 57 var out = kernelBetainc( NaN, 1.0, 1.0, true, true ); 58 // returns [ NaN, NaN ] 59 60 out = kernelBetainc( 0.8, NaN, 1.0, true, true ); 61 // returns [ NaN, NaN ] 62 63 out = kernelBetainc( 0.8, 1.0, NaN, true, true ); 64 // returns [ NaN, NaN ] 65 ``` 66 67 If `x` is outside the interval `[0,1]`, the function returns `[ NaN, NaN ]`. 68 69 ```javascript 70 var out = kernelBetainc( 1.5, 1.0, 1.0, true, true ); 71 // returns [ NaN, NaN ] 72 73 out = kernelBetainc( -0.5, 1.0, 1.0, true, true ); 74 // returns [ NaN, NaN ] 75 ``` 76 77 If `a` or `b` is negative, the function returns `[ NaN, NaN ]`. 78 79 ```javascript 80 var out = kernelBetainc( 0.5, -2.0, 2.0, true, true ); 81 // returns [ NaN, NaN ] 82 83 out = kernelBetainc( 0.5, 2.0, -2.0, true, true ); 84 // returns [ NaN, NaN ] 85 ``` 86 87 #### kernelBetainc.assign( x, a, b, regularized, upper, out, stride, offset ) 88 89 Evaluates the [incomplete beta function][incomplete-beta-function] and its first derivative for parameters `x`, `a > 0` and `b > 0` and assigns results to a provided output array. 90 91 ```javascript 92 var Float64Array = require( '@stdlib/array/float64' ); 93 94 var out = new Float64Array( 2 ); 95 var v = kernelBetainc.assign( 0.2, 1.0, 2.0, true, true, out, 1, 0 ); 96 // returns <Float64Array>[ 0.64, 1.6 ] 97 98 var bool = ( v === out ); 99 // returns true 100 ``` 101 102 The `offset` parameter specifies the index of the first output array element, and the `stride` parameter specifies the stride length between consecutive output array elements. 103 104 </section> 105 106 <!-- /.usage --> 107 108 <section class="examples"> 109 110 ## Examples 111 112 <!-- eslint no-undef: "error" --> 113 114 ```javascript 115 var randu = require( '@stdlib/random/base/randu' ); 116 var kernelBetainc = require( '@stdlib/math/base/special/kernel-betainc' ); 117 118 var out; 119 var i; 120 var x; 121 var a; 122 var b; 123 124 out = [ 0.0, 0.0 ]; 125 for ( i = 0; i < 100; i++ ) { 126 x = randu(); 127 a = randu() * 10.0; 128 b = randu() * 10.0; 129 kernelBetainc( x, a, b, true, false, out, 1, 0 ); 130 console.log( 'x: %d, \t a: %d, \t b: %d, \t f(x,a,b): %d, \t f^1(x,a,b): %d', x.toFixed( 4 ), a.toFixed( 4 ), b.toFixed( 4 ), out[ 0 ].toFixed( 4 ), out[ 1 ].toFixed( 4 ) ); 131 } 132 ``` 133 134 </section> 135 136 <!-- /.examples --> 137 138 <section class="links"> 139 140 [incomplete-beta-function]: https://en.wikipedia.org/wiki/Incomplete_beta_function 141 142 </section> 143 144 <!-- /.links -->