README.md (2637B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2019 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 # expit 22 23 > Compute the [standard logistic][logistic-function] function. 24 25 <section class="intro"> 26 27 The [standard logistic][logistic-function] function, also called the expit function, inverse logit, or sigmoid function, is defined as the [logistic][logistic-function] function with parameters (`k = 1`, `x0 = 0`, `L = 1`). 28 29 <!-- <equation class="equation" label="eq:expit_function" align="center" raw="\begin{aligned}\operatorname{expit}(x) &= \frac{1}{1+e^{-x}} \\ &= \frac{e^{x}}{e^{x}+1} \\ &= \frac{1}{2} + \frac{1}{2}\tanh\frac{x}{2} \end{aligned}" alt="Standard logistic function."> --> 30 31 <div class="equation" align="center" data-raw-text="\begin{aligned}\operatorname{expit}(x) &= \frac{1}{1+e^{-x}} \\ &= \frac{e^{x}}{e^{x}+1} \\ &= \frac{1}{2} + \frac{1}{2}\tanh\frac{x}{2} \end{aligned}" data-equation="eq:expit_function"> 32 <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@011d8b8e35ceb466ad31f5484e176ccaeaa087a2/lib/node_modules/@stdlib/math/base/special/expit/docs/img/equation_expit_function.svg" alt="Standard logistic function."> 33 <br> 34 </div> 35 36 <!-- </equation> --> 37 38 </section> 39 40 <!-- /.intro --> 41 42 <section class="usage"> 43 44 ## Usage 45 46 ```javascript 47 var expit = require( '@stdlib/math/base/special/expit' ); 48 ``` 49 50 #### expit( x ) 51 52 Computes the [standard logistic][logistic-function] function. 53 54 ```javascript 55 var v = expit( 0.0 ); 56 // returns ~0.5 57 58 v = expit( 1.0 ); 59 // returns ~0.731 60 61 v = expit( -1.0 ); 62 // returns ~0.269 63 64 v = expit( Infinity ); 65 // returns 1.0 66 67 v = expit( NaN ); 68 // returns NaN 69 ``` 70 71 </section> 72 73 <!-- /.usage --> 74 75 <section class="examples"> 76 77 ## Examples 78 79 <!-- eslint no-undef: "error" --> 80 81 ```javascript 82 var randu = require( '@stdlib/random/base/randu' ); 83 var expit = require( '@stdlib/math/base/special/expit' ); 84 85 var x; 86 var i; 87 88 for ( i = 0; i < 100; i++ ) { 89 x = randu(); 90 console.log( 'expit(%d) = %d', x, expit( x ) ); 91 } 92 ``` 93 94 </section> 95 96 <!-- /.examples --> 97 98 <section class="links"> 99 100 [logistic-function]: https://en.wikipedia.org/wiki/Logistic_function 101 102 </section> 103 104 <!-- /.links -->