README.md (4329B)
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 # Skewness 22 23 > [Triangular][triangular-distribution] distribution [skewness][skewness]. 24 25 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> 26 27 <section class="intro"> 28 29 The [skewness][skewness] for a [triangular][triangular-distribution] random variable is 30 31 <!-- <equation class="equation" label="eq:triangular_skewness" align="center" raw="\operatorname{skew}\left( X \right) = \frac{{\sqrt 2}(a\!+\!b\!-\!2c)(2a\!-\!b\!-\!c)(a\!-\!2b\!+\!c)}{5(a^{2}\!+\!b^{2}\!+\!c^{2}\!-\!ab\!-\!ac\!-\!bc)^{{\frac{3}{2}}}}" alt="Skewness for a triangular distribution."> --> 32 33 <div class="equation" align="center" data-raw-text="\operatorname{skew}\left( X \right) = \frac{{\sqrt 2}(a\!+\!b\!-\!2c)(2a\!-\!b\!-\!c)(a\!-\!2b\!+\!c)}{5(a^{2}\!+\!b^{2}\!+\!c^{2}\!-\!ab\!-\!ac\!-\!bc)^{{\frac{3}{2}}}}" data-equation="eq:triangular_skewness"> 34 <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@556e0ebc42f54244079cecc91c0883bb6c442244/lib/node_modules/@stdlib/stats/base/dists/triangular/skewness/docs/img/equation_triangular_skewness.svg" alt="Skewness for a triangular distribution."> 35 <br> 36 </div> 37 38 <!-- </equation> --> 39 40 where `a` is the lower limit, `b` is the upper limit and `c` is the mode. 41 42 </section> 43 44 <!-- /.intro --> 45 46 <!-- Package usage documentation. --> 47 48 <section class="usage"> 49 50 ## Usage 51 52 ```javascript 53 var skewness = require( '@stdlib/stats/base/dists/triangular/skewness' ); 54 ``` 55 56 #### skewness( a, b, c ) 57 58 Returns the [skewness][skewness] of a [triangular][triangular-distribution] distribution with minimum support `a`, maximum support`b`, and mode `c`. 59 60 ```javascript 61 var v = skewness( 0.0, 1.0, 0.8 ); 62 // returns ~-0.476 63 64 v = skewness( 4.0, 12.0, 5.0 ); 65 // returns ~0.532 66 67 v = skewness( 2.0, 8.0, 5.0 ); 68 // returns 0.0 69 ``` 70 71 If provided `NaN` as any argument, the function returns `NaN`. 72 73 ```javascript 74 var v = skewness( NaN, 4.0, 2.0 ); 75 // returns NaN 76 77 v = skewness( 0.0, NaN, 2.0 ); 78 // returns NaN 79 80 v = skewness( 0.0, 4.0, NaN ); 81 // returns NaN 82 ``` 83 84 If provided parameters not satisfying `a <= c <= b`, the function returns `NaN`. 85 86 ```javascript 87 var y = skewness( 1.0, 0.0, 1.5 ); 88 // returns NaN 89 90 y = skewness( 0.0, 1.0, -1.0 ); 91 // returns NaN 92 93 y = skewness( 0.0, -1.0, 0.5 ); 94 // returns NaN 95 ``` 96 97 </section> 98 99 <!-- /.usage --> 100 101 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 102 103 <section class="notes"> 104 105 </section> 106 107 <!-- /.notes --> 108 109 <!-- Package usage examples. --> 110 111 <section class="examples"> 112 113 ## Examples 114 115 <!-- eslint no-undef: "error" --> 116 117 ```javascript 118 var randu = require( '@stdlib/random/base/randu' ); 119 var skewness = require( '@stdlib/stats/base/dists/triangular/skewness' ); 120 121 var a; 122 var b; 123 var c; 124 var v; 125 var i; 126 127 for ( i = 0; i < 10; i++ ) { 128 a = ( randu()*10.0 ); 129 b = ( randu()*10.0 ) + a; 130 c = ( randu()*( b-a ) ) + a; 131 v = skewness( a, b, c ); 132 console.log( 'a: %d, b: %d, c: %d, skew(X;a,b,c): %d', a.toFixed( 4 ), b.toFixed( 4 ), c.toFixed( 4 ), v.toFixed( 4 ) ); 133 } 134 ``` 135 136 </section> 137 138 <!-- /.examples --> 139 140 <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 141 142 <section class="references"> 143 144 </section> 145 146 <!-- /.references --> 147 148 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 149 150 <section class="links"> 151 152 [triangular-distribution]: https://en.wikipedia.org/wiki/Triangular_distribution 153 154 [skewness]: https://en.wikipedia.org/wiki/Skewness 155 156 </section> 157 158 <!-- /.links -->