|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2026 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 | +> [Wald][wald-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 [Wald][wald-distribution] random variable with mean `μ` and shape parameter `λ > 0` is |
| 30 | + |
| 31 | +<!-- <equation class="equation" label="eq:wald_skewness" align="center" raw="\operatorname{skew}\left( X \right) = 3 \sqrt{\frac{\mu}{\lambda}}" alt="Skewness for a Wald distribution."> --> |
| 32 | + |
| 33 | +```math |
| 34 | +\mathop{\mathrm{skew}}\left( X \right) = 3 \sqrt{\frac{\mu}{\lambda}} |
| 35 | +``` |
| 36 | + |
| 37 | +<!-- <div class="equation" align="center" data-raw-text="\operatorname{skew}\left( X \right) = 3 \sqrt{\frac{\mu}{\lambda}}" data-equation="eq:wald_skewness"> |
| 38 | +</div> --> |
| 39 | + |
| 40 | +<!-- </equation> --> |
| 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/wald/skewness' ); |
| 54 | +``` |
| 55 | + |
| 56 | +#### skewness( mu, lambda ) |
| 57 | + |
| 58 | +Returns the [skewness][skewness] for a [Wald][wald-distribution] distribution with parameters `mu` (mean) and `lambda` (shape parameter). |
| 59 | + |
| 60 | +```javascript |
| 61 | +var y = skewness( 2.0, 1.0 ); |
| 62 | +// returns ~4.243 |
| 63 | + |
| 64 | +y = skewness( 1.0, 1.0 ); |
| 65 | +// returns 3.0 |
| 66 | + |
| 67 | +y = skewness( 0.0, 1.0 ); |
| 68 | +// returns NaN |
| 69 | +``` |
| 70 | + |
| 71 | +If provided `NaN` as any argument, the function returns `NaN`. |
| 72 | + |
| 73 | +```javascript |
| 74 | +var y = skewness( NaN, 1.0 ); |
| 75 | +// returns NaN |
| 76 | + |
| 77 | +y = skewness( 0.0, NaN ); |
| 78 | +// returns NaN |
| 79 | +``` |
| 80 | + |
| 81 | +If provided `mu <= 0` or `lambda <= 0`, the function returns `NaN`. |
| 82 | + |
| 83 | +```javascript |
| 84 | +var y = skewness( 0.0, 0.0 ); |
| 85 | +// returns NaN |
| 86 | + |
| 87 | +y = skewness( 0.0, -1.0 ); |
| 88 | +// returns NaN |
| 89 | + |
| 90 | +y = skewness( -1.0, 0.0 ); |
| 91 | +// returns NaN |
| 92 | +``` |
| 93 | + |
| 94 | +</section> |
| 95 | + |
| 96 | +<!-- /.usage --> |
| 97 | + |
| 98 | +<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 99 | + |
| 100 | +<section class="notes"> |
| 101 | + |
| 102 | +</section> |
| 103 | + |
| 104 | +<!-- /.notes --> |
| 105 | + |
| 106 | +<!-- Package usage examples. --> |
| 107 | + |
| 108 | +<section class="examples"> |
| 109 | + |
| 110 | +## Examples |
| 111 | + |
| 112 | +<!-- eslint no-undef: "error" --> |
| 113 | + |
| 114 | +```javascript |
| 115 | +var uniform = require( '@stdlib/random/array/uniform' ); |
| 116 | +var logEachMap = require( '@stdlib/console/log-each-map' ); |
| 117 | +var EPS = require( '@stdlib/constants/float64/eps' ); |
| 118 | +var skewness = require( '@stdlib/stats/base/dists/wald/skewness' ); |
| 119 | + |
| 120 | +var opts = { |
| 121 | + 'dtype': 'float64' |
| 122 | +}; |
| 123 | +var mu = uniform( 10, EPS, 10.0, opts ); |
| 124 | +var lambda = uniform( 10, EPS, 20.0, opts ); |
| 125 | + |
| 126 | +logEachMap( 'µ: %0.4f, λ: %0.4f, skew(X;µ,λ): %0.4f', mu, lambda, skewness ); |
| 127 | +``` |
| 128 | + |
| 129 | +</section> |
| 130 | + |
| 131 | +<!-- /.examples --> |
| 132 | + |
| 133 | +<!-- C interface documentation. --> |
| 134 | + |
| 135 | +* * * |
| 136 | + |
| 137 | +<section class="c"> |
| 138 | + |
| 139 | +## C APIs |
| 140 | + |
| 141 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 142 | + |
| 143 | +<section class="intro"> |
| 144 | + |
| 145 | +</section> |
| 146 | + |
| 147 | +<!-- /.intro --> |
| 148 | + |
| 149 | +<!-- C usage documentation. --> |
| 150 | + |
| 151 | +<section class="usage"> |
| 152 | + |
| 153 | +### Usage |
| 154 | + |
| 155 | +```c |
| 156 | +#include "stdlib/stats/base/dists/wald/skewness.h" |
| 157 | +``` |
| 158 | + |
| 159 | +#### stdlib_base_dists_wald_skewness( mu, lambda ) |
| 160 | + |
| 161 | +Returns the [skewness][skewness] of a [Wald][wald-distribution] distribution with mean `mu` and shape parameter `lambda`. |
| 162 | + |
| 163 | +```c |
| 164 | +double out = stdlib_base_dists_wald_skewness( 2.0, 1.0 ); |
| 165 | +// returns ~4.243 |
| 166 | +``` |
| 167 | + |
| 168 | +The function accepts the following arguments: |
| 169 | + |
| 170 | +- **mu**: `[in] double` mean. |
| 171 | +- **lambda**: `[in] double` shape parameter. |
| 172 | + |
| 173 | +```c |
| 174 | +double stdlib_base_dists_wald_skewness( const double mu, const double lambda ); |
| 175 | +``` |
| 176 | +
|
| 177 | +</section> |
| 178 | +
|
| 179 | +<!-- /.usage --> |
| 180 | +
|
| 181 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 182 | +
|
| 183 | +<section class="notes"> |
| 184 | +
|
| 185 | +</section> |
| 186 | +
|
| 187 | +<!-- /.notes --> |
| 188 | +
|
| 189 | +<!-- C API usage examples. --> |
| 190 | +
|
| 191 | +<section class="examples"> |
| 192 | +
|
| 193 | +### Examples |
| 194 | +
|
| 195 | +```c |
| 196 | +#include "stdlib/stats/base/dists/wald/skewness.h" |
| 197 | +#include <stdlib.h> |
| 198 | +#include <stdio.h> |
| 199 | +
|
| 200 | +static double random_uniform( const double min, const double max ) { |
| 201 | + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); |
| 202 | + return min + ( v*(max-min) ); |
| 203 | +} |
| 204 | +
|
| 205 | +int main( void ) { |
| 206 | + double lambda; |
| 207 | + double mu; |
| 208 | + double y; |
| 209 | + int i; |
| 210 | +
|
| 211 | + for ( i = 0; i < 10; i++ ) { |
| 212 | + mu = random_uniform( 0.1, 5.0 ); |
| 213 | + lambda = random_uniform( 0.1, 20.0 ); |
| 214 | + y = stdlib_base_dists_wald_skewness( mu, lambda ); |
| 215 | + printf( "µ: %.4f, λ: %.4f, skew(X;µ,λ): %.4f\n", mu, lambda, y ); |
| 216 | + } |
| 217 | +} |
| 218 | +``` |
| 219 | + |
| 220 | +</section> |
| 221 | + |
| 222 | +<!-- /.examples --> |
| 223 | + |
| 224 | +</section> |
| 225 | + |
| 226 | +<!-- /.c --> |
| 227 | + |
| 228 | +<!-- 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. --> |
| 229 | + |
| 230 | +<section class="references"> |
| 231 | + |
| 232 | +</section> |
| 233 | + |
| 234 | +<!-- /.references --> |
| 235 | + |
| 236 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 237 | + |
| 238 | +<section class="related"> |
| 239 | + |
| 240 | +</section> |
| 241 | + |
| 242 | +<!-- /.related --> |
| 243 | + |
| 244 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 245 | + |
| 246 | +<section class="links"> |
| 247 | + |
| 248 | +[wald-distribution]: https://en.wikipedia.org/wiki/Inverse_Gaussian_distribution |
| 249 | + |
| 250 | +[skewness]: https://en.wikipedia.org/wiki/Skewness |
| 251 | + |
| 252 | +</section> |
| 253 | + |
| 254 | +<!-- /.links --> |
0 commit comments