|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2025 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 | +# Variance |
| 22 | + |
| 23 | +> [Bradford][bradford-distribution] distribution [variance][variance]. |
| 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 [variance][variance] for a [Bradford][bradford-distribution] random variable is |
| 30 | + |
| 31 | +<!-- <equation class="equation" label="eq:bradford_variance" align="center" raw="\mathop{\mathrm{Var}}\left( X \right) = \frac{(c+2) \ln(1+c) - 2c}{2c (\ln(1+c))^2}" alt="Variance for a Bradford distribution."> --> |
| 32 | + |
| 33 | +```math |
| 34 | +\mathop{\mathrm{Var}}\left( X \right) = \frac{(c+2) \ln(1+c) - 2c}{2c (\ln(1+c))^2} |
| 35 | +``` |
| 36 | + |
| 37 | +<!-- <div class="equation" align="center" data-raw-text="\mathop{\mathrm{Var}}\left( X \right) = \frac{(c+2) \ln(1+c) - 2c}{2c (\ln(1+c))^2}" data-equation="eq:bradford_variance"> |
| 38 | + <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@591cf9d5c3a0cd3c1ceec961e5c49d73a68374cb/lib/node_modules/@stdlib/stats/base/dists/bradford/variance/docs/img/equation_bradford_variance.svg" alt="Variance for a Bradford distribution."> |
| 39 | + <br> |
| 40 | +</div> --> |
| 41 | + |
| 42 | +<!-- </equation> --> |
| 43 | + |
| 44 | +where `c` is the shape parameter. |
| 45 | + |
| 46 | +</section> |
| 47 | + |
| 48 | +<!-- /.intro --> |
| 49 | + |
| 50 | +<!-- Package usage documentation. --> |
| 51 | + |
| 52 | +<section class="usage"> |
| 53 | + |
| 54 | +## Usage |
| 55 | + |
| 56 | +```javascript |
| 57 | +var variance = require( '@stdlib/stats/base/dists/bradford/variance' ); |
| 58 | +``` |
| 59 | + |
| 60 | +#### variance( c ) |
| 61 | + |
| 62 | +Returns the [variance][variance] of a [Bradford][bradford-distribution] distribution with shape parameter `c`. |
| 63 | + |
| 64 | +```javascript |
| 65 | +var v = variance( 0.1 ); |
| 66 | +// returns ~0.083 |
| 67 | + |
| 68 | +v = variance( 10.0 ); |
| 69 | +// returns ~0.076 |
| 70 | +``` |
| 71 | + |
| 72 | +If provided a shape parameter `c <= 0`, the function returns `NaN`. |
| 73 | + |
| 74 | +```javascript |
| 75 | +var v = variance( 0.0 ); |
| 76 | +// returns NaN |
| 77 | + |
| 78 | +v = variance( -1.5 ); |
| 79 | +// returns NaN |
| 80 | +``` |
| 81 | + |
| 82 | +</section> |
| 83 | + |
| 84 | +<!-- /.usage --> |
| 85 | + |
| 86 | +<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 87 | + |
| 88 | +<section class="notes"> |
| 89 | + |
| 90 | +</section> |
| 91 | + |
| 92 | +<!-- /.notes --> |
| 93 | + |
| 94 | +<!-- Package usage examples. --> |
| 95 | + |
| 96 | +<section class="examples"> |
| 97 | + |
| 98 | +## Examples |
| 99 | + |
| 100 | +<!-- eslint no-undef: "error" --> |
| 101 | + |
| 102 | +```javascript |
| 103 | +var uniform = require( '@stdlib/random/array/uniform' ); |
| 104 | +var variance = require( '@stdlib/stats/base/dists/bradford/variance' ); |
| 105 | + |
| 106 | +var c = uniform( 10, 0.1, 10.0 ); |
| 107 | + |
| 108 | +var v; |
| 109 | +var i; |
| 110 | +for ( i = 0; i < c.length; i++ ) { |
| 111 | + v = variance( c[ i ] ); |
| 112 | + console.log( 'c: %d, Var(X;c): %d', c[ i ].toFixed( 4 ), v.toFixed( 4 ) ); |
| 113 | +} |
| 114 | +``` |
| 115 | + |
| 116 | +</section> |
| 117 | + |
| 118 | +<!-- /.examples --> |
| 119 | + |
| 120 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 121 | + |
| 122 | +<section class="related"> |
| 123 | + |
| 124 | +</section> |
| 125 | + |
| 126 | +<!-- /.related --> |
| 127 | + |
| 128 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 129 | + |
| 130 | +<section class="links"> |
| 131 | + |
| 132 | +[bradford-distribution]: https://en.wikipedia.org/wiki/Bradford%27s_law |
| 133 | + |
| 134 | +[variance]: https://en.wikipedia.org/wiki/Variance |
| 135 | + |
| 136 | +</section> |
| 137 | + |
| 138 | +<!-- /.links --> |
0 commit comments