README.md (2458B)
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 # logit 22 23 > Compute the [logit][logit] function. 24 25 <section class="intro"> 26 27 The [logit][logit] function is defined as the logarithm of the odds `p / (1-p)`; i.e., 28 29 <!-- <equation class="equation" label="eq:logit_function" align="center" raw="\operatorname{logit}(p)=\log \left({\frac {p}{1-p}}\right)" alt="Logit function."> --> 30 31 <div class="equation" align="center" data-raw-text="\operatorname{logit}(p)=\log \left({\frac {p}{1-p}}\right)" data-equation="eq:logit_function"> 32 <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/logit/docs/img/equation_logit_function.svg" alt="Logit function."> 33 <br> 34 </div> 35 36 <!-- </equation> --> 37 38 The [logit][logit] function is the inverse of the [standard logistic][standard-logistic] function, sometimes also called the sigmoid function. 39 40 </section> 41 42 <!-- /.intro --> 43 44 <section class="usage"> 45 46 ## Usage 47 48 ```javascript 49 var logit = require( '@stdlib/math/base/special/logit' ); 50 ``` 51 52 #### logit( p ) 53 54 Computes the [logit][logit] function. 55 56 ```javascript 57 var v = logit( 0.2 ); 58 // returns ~-1.386 59 60 v = logit( 0.9 ); 61 // returns ~2.197 62 ``` 63 64 If `p < 0` or `p > 1`, the function returns `NaN`. 65 66 ```javascript 67 var v = logit( 1.3 ); 68 // returns NaN 69 70 v = logit( -0.2 ); 71 // returns NaN 72 ``` 73 74 </section> 75 76 <!-- /.usage --> 77 78 <section class="examples"> 79 80 ## Examples 81 82 <!-- eslint no-undef: "error" --> 83 84 ```javascript 85 var randu = require( '@stdlib/random/base/randu' ); 86 var logit = require( '@stdlib/math/base/special/logit' ); 87 88 var p; 89 var i; 90 91 for ( i = 0; i < 100; i++ ) { 92 p = randu(); 93 console.log( 'logit(%d) = %d', p, logit( p ) ); 94 } 95 ``` 96 97 </section> 98 99 <!-- /.examples --> 100 101 <section class="links"> 102 103 [logit]: https://en.wikipedia.org/wiki/Logit 104 105 [standard-logistic]: https://en.wikipedia.org/wiki/Logistic_function 106 107 </section> 108 109 <!-- /.links -->