|
| 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 | +# Kurtosis |
| 22 | + |
| 23 | +> [Half-normal][halfnormal-distribution] distribution [excess kurtosis][kurtosis]. |
| 24 | +
|
| 25 | +<section class="intro"> |
| 26 | + |
| 27 | +The [excess kurtosis][kurtosis] of a [half-normal][halfnormal-distribution] distribution with scale `sigma > 0` is |
| 28 | + |
| 29 | +<!-- <equation class="equation" label="eq:halfnormal_kurtosis" align="center" raw="\gamma_2 = \frac{8(\pi-3)}{(\pi-2)^2}" alt="Excess kurtosis for a half-normal distribution."> --> |
| 30 | + |
| 31 | +```math |
| 32 | +\gamma_2 = \frac{8(\pi-3)}{(\pi-2)^2} |
| 33 | +``` |
| 34 | + |
| 35 | +<!-- <div class="equation" align="center" data-raw-text="\gamma_2 = \frac{8(\pi-3)}{(\pi-2)^2}" data-equation="eq:halfnormal_kurtosis"> |
| 36 | + <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@2d398018e6a1275033c4ad59453a233302c3409d/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/docs/img/equation_halfnormal_kurtosis.svg" alt="Excess kurtosis for a half-normal distribution."> |
| 37 | + <br> |
| 38 | +</div> --> |
| 39 | + |
| 40 | +<!-- </equation> --> |
| 41 | + |
| 42 | +</section> |
| 43 | + |
| 44 | +<!-- /.intro --> |
| 45 | + |
| 46 | +<section class="usage"> |
| 47 | + |
| 48 | +## Usage |
| 49 | + |
| 50 | +```javascript |
| 51 | +var kurtosis = require( '@stdlib/stats/base/dists/halfnormal/kurtosis' ); |
| 52 | +``` |
| 53 | + |
| 54 | +#### kurtosis( sigma ) |
| 55 | + |
| 56 | +Returns the [excess kurtosis][kurtosis] of a [half-normal][halfnormal-distribution] distribution with scale parameter `sigma`. |
| 57 | + |
| 58 | +```javascript |
| 59 | +var x = kurtosis( 1.0 ); |
| 60 | +// returns ~0.869 |
| 61 | + |
| 62 | +var y = kurtosis( 4.0 ); |
| 63 | +// returns ~0.869 |
| 64 | +``` |
| 65 | + |
| 66 | +If provided `sigma <= 0`, the function returns `NaN`. |
| 67 | + |
| 68 | +```javascript |
| 69 | +var x = kurtosis( 0.0 ); |
| 70 | +// returns NaN |
| 71 | + |
| 72 | +var y = kurtosis( -1.0 ); |
| 73 | +// returns NaN |
| 74 | +``` |
| 75 | + |
| 76 | +</section> |
| 77 | + |
| 78 | +<!-- /.usage --> |
| 79 | + |
| 80 | +<section class="examples"> |
| 81 | + |
| 82 | +## Examples |
| 83 | + |
| 84 | +<!-- eslint no-undef: "error" --> |
| 85 | + |
| 86 | +```javascript |
| 87 | +var uniform = require( '@stdlib/random/array/uniform' ); |
| 88 | +var logEachMap = require( '@stdlib/console/log-each-map' ); |
| 89 | +var kurtosis = require( '@stdlib/stats/base/dists/halfnormal/kurtosis' ); |
| 90 | + |
| 91 | +var opts = { |
| 92 | + 'dtype': 'float64' |
| 93 | +}; |
| 94 | +var sigma = uniform( 10, 0.0, 20.0, opts ); |
| 95 | + |
| 96 | +logEachMap( 'σ: %0.4f, Kurt(X;σ): %0.4f', sigma, kurtosis ); |
| 97 | +``` |
| 98 | + |
| 99 | +</section> |
| 100 | + |
| 101 | +<!-- /.examples --> |
| 102 | + |
| 103 | +<!-- C interface documentation. --> |
| 104 | + |
| 105 | +* * * |
| 106 | + |
| 107 | +<section class="c"> |
| 108 | + |
| 109 | +## C APIs |
| 110 | + |
| 111 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 112 | + |
| 113 | +<section class="intro"> |
| 114 | + |
| 115 | +</section> |
| 116 | + |
| 117 | +<!-- /.intro --> |
| 118 | + |
| 119 | +<!-- C usage documentation. --> |
| 120 | + |
| 121 | +<section class="usage"> |
| 122 | + |
| 123 | +### Usage |
| 124 | + |
| 125 | +```c |
| 126 | +#include "stdlib/stats/base/dists/halfnormal/kurtosis.h" |
| 127 | +``` |
| 128 | + |
| 129 | +#### stdlib_base_dists_halfnormal_kurtosis( sigma ) |
| 130 | + |
| 131 | +Returns the [excess kurtosis][kurtosis] of a [half-normal][halfnormal-distribution] distribution with scale parameter `sigma`. |
| 132 | + |
| 133 | +```c |
| 134 | +double out = stdlib_base_dists_halfnormal_kurtosis( 1.0 ); |
| 135 | +// returns ~0.869 |
| 136 | +``` |
| 137 | + |
| 138 | +The function accepts the following arguments: |
| 139 | + |
| 140 | +- **sigma**: `[in] double` scale parameter. |
| 141 | + |
| 142 | +```c |
| 143 | +double stdlib_base_dists_halfnormal_kurtosis( const double sigma ); |
| 144 | +``` |
| 145 | +
|
| 146 | +</section> |
| 147 | +
|
| 148 | +<!-- /.usage --> |
| 149 | +
|
| 150 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 151 | +
|
| 152 | +<section class="notes"> |
| 153 | +
|
| 154 | +</section> |
| 155 | +
|
| 156 | +<!-- /.notes --> |
| 157 | +
|
| 158 | +<!-- C API usage examples. --> |
| 159 | +
|
| 160 | +<section class="examples"> |
| 161 | +
|
| 162 | +### Examples |
| 163 | +
|
| 164 | +```c |
| 165 | +#include "stdlib/stats/base/dists/halfnormal/kurtosis.h" |
| 166 | +#include <stdlib.h> |
| 167 | +#include <stdio.h> |
| 168 | +
|
| 169 | +static double random_uniform( const double min, const double max ) { |
| 170 | + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); |
| 171 | + return min + ( v*(max-min) ); |
| 172 | +} |
| 173 | +
|
| 174 | +int main( void ) { |
| 175 | + double sigma; |
| 176 | + double y; |
| 177 | + int i; |
| 178 | +
|
| 179 | + for ( i = 0; i < 10; i++ ) { |
| 180 | + sigma = random_uniform( 0.0, 20.0 ); |
| 181 | + y = stdlib_base_dists_halfnormal_kurtosis( sigma ); |
| 182 | + printf( "σ: %lf, Kurt(σ): %lf\n", sigma, y ); |
| 183 | + } |
| 184 | +} |
| 185 | +``` |
| 186 | + |
| 187 | +</section> |
| 188 | + |
| 189 | +<!-- /.examples --> |
| 190 | + |
| 191 | +</section> |
| 192 | + |
| 193 | +<!-- /.c --> |
| 194 | + |
| 195 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 196 | + |
| 197 | +<section class="related"> |
| 198 | + |
| 199 | +</section> |
| 200 | + |
| 201 | +<!-- /.related --> |
| 202 | + |
| 203 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 204 | + |
| 205 | +<section class="links"> |
| 206 | + |
| 207 | +[halfnormal-distribution]: https://en.wikipedia.org/wiki/Half-normal_distribution |
| 208 | + |
| 209 | +[kurtosis]: https://en.wikipedia.org/wiki/Kurtosis |
| 210 | + |
| 211 | +</section> |
| 212 | + |
| 213 | +<!-- /.links --> |
0 commit comments